Check-in Number:
|
37 | |
Date: |
2007-Apr-13 19:18:08 (local)
2007-Apr-13 17:18:08 (UTC) |
User: | rse |
Branch: | |
Comment: |
polish text
|
Tickets: |
|
Inspections: |
|
Files: |
|
Modified: jquery/jquery.xsajax.html
===================================================================
--- jquery/jquery.xsajax.html 2007-04-13 14:39:58 UTC (rev 36)
+++ jquery/jquery.xsajax.html 2007-04-13 17:18:08 UTC (rev 37)
@@ -3,6 +3,9 @@
<html>
<head>
<title>jQuery XS AJAX Plugin</title>
+ <style type="text/css">
+ body { margin-left: auto; margin-right: auto; width: 600px; }
+ </style>
</head>
<body>
<h1>jQuery XS AJAX Plugin</h1>
@@ -11,7 +14,7 @@
It is well known that with the help of a dynamically generated
DOM node corresponding to a XHTML <tt><script></tt>
- element one can achieve a portable cross-site (XS) variation
+ element, one can achieve a portable cross-site (XS) variation
of an AJAX-style client-server communication as the
<tt><script></tt> element is <i>not</i> staying under the
"same-origin security policy" which restricts all the regular
@@ -23,10 +26,12 @@
hrf="jquery.xsajax.js"><tt>jquery.xsajax.js</tt></a> is a <a
href="http://jquery.com/">jQuery</a> plugin, providing an
abstraction layer for this functionality by resembling the
- standard AJAX-based <tt>jQuery.getScript(url, callback)</tt> function with a
- companion <tt>jQuery.getScriptXS(url, callback)</tt> function.
+ standard AJAX-based <tt>jQuery.getScript(url, callback)</tt>
+ function with a companion <tt>jQuery.getScriptXS(url,
+ callback)</tt> function.
- <p/>
+ <h2>Hints</h2>
+
Notice 1: the point of this plugin is not the bare dynamic
generation of the <tt><script></tt>. The point is
that a callback function is executed once the script was
@@ -43,19 +48,22 @@
customer login form. Once the customer was authenticated,
a cookie containing a "certificate" should be set. Setting
this for ".example.com" is trivial, but how do you at the
- same time set it for all three domains? The solution is
- this: www.example.com/login uses jQuery.getScriptXS() to
- send the issued "certificate" via a query string to both
- www.example.net/reflector and www.example.org/reflector.
- Behind those URLs a small CGI just converts the "certificate"
- in the query string into a corresponding HTTP response cookie
- (now for its own domain!) and returns even a possibly empty
- JavaScript script. Once www.example.com/login has received the
- two final notification (via the callback function) that both
- scripts were loaded, it knows that the two third-party cookies
- were set and can proceed by forwarding to the next page in
- sequence. Last hint: keep P3P in mind for MSIE when setting
- the cookie in the HTTP response ;-)
+ same time set it for all three domains?
+
+ <p/>
+ The solution is this: www.example.com/login uses
+ jQuery.getScriptXS() to send the issued "certificate"
+ via a query string to both www.example.net/reflector and
+ www.example.org/reflector. Behind those URLs a small CGI
+ just converts the "certificate" in the query string into a
+ corresponding HTTP response cookie (now for its own domain!)
+ and returns even a possibly empty JavaScript script. Once
+ www.example.com/login has received the two final notification
+ (via the callback function) that both scripts were loaded, it
+ knows that the two third-party cookies were set and can proceed
+ by forwarding to the next page in sequence. Last hint: keep P3P
+ in mind for MSIE when setting the cookie in the HTTP response
+ ;-)
<h2>Example</h2>
@@ -62,19 +70,19 @@
<ul>
<li>http://www.example<b>.com</b>/test.html:<br/>
<pre>
- <script type="text/javascript">
- jQuery.$foo = "bar";
- alert("jQuery.$foo="+jQuery.$foo);
- jQuery.getScriptXS(
- "http://www.example<b>.net</b>/test.js",
- function () { alert("jQuery.$foo="+jQuery.$foo); }
- );
- </script>
+<script type="text/javascript">
+ jQuery.$foo = "bar";
+ alert("jQuery.$foo="+jQuery.$foo);
+ jQuery.getScriptXS(
+ "http://www.example<b>.net</b>/test.js",
+ function () { alert("jQuery.$foo="+jQuery.$foo); }
+ );
+</script>
</pre>
</li>
<li>http://www.example<b>.net</b>/test.js<br/>
<pre>
- jQuery.$foo = "quux";
+jQuery.$foo = "quux";
</pre>
</li>
</ul>