tot - jquery/jquery.xsajax.html 37
Not logged in
[Browse]  [Directory]  [Home]  [Login
[Reports]  [Search]  [Timeline
jquery/jquery.xsajax.html 37
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        <title>jQuery XS AJAX Plugin</title>
        <style type="text/css">
            body { margin-left: auto; margin-right: auto; width: 600px; }
        <h1>jQuery XS AJAX Plugin</h1>


        It is well known that with the help of a dynamically generated
        DOM node corresponding to a XHTML <tt>&lt;script&gt;</tt>
        element, one can achieve a portable cross-site (XS) variation
        of an AJAX-style client-server communication as the
        <tt>&lt;script&gt;</tt> element is <i>not</i> staying under the
        "same-origin security policy" which restricts all the regular
        AJAX methods. This allows one to asynchronously load JavaScript
        code from a third-party URL.

        The JavaScript code in <a
        hrf="jquery.xsajax.js"><tt>jquery.xsajax.js</tt></a> is a <a
        href="">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.


        Notice 1: the point of this plugin is not the bare dynamic
        generation of the <tt>&lt;script&gt;</tt>. The point is
        that a callback function is executed once the script was
        loaded and executed by the browser and that the generated
        <tt>&lt;script&gt;</tt> is automatically garbage collected from
        the DOM again afterwards.

        Notice 2: the possibility to load a JavaScript file from a      
        sibling but third-party URL is also of great interest when      
        one wishes to set cookies for the third-party URLs. Suppose     
        you have three websites, and    and on you have your      
        customer login form. Once the customer was authenticated,       
        a cookie containing a "certificate" should be set. Setting      
        this for "" is trivial, but how do you at the       
        same time set it for all three domains? 
        The solution is this: uses
        jQuery.getScriptXS() to send the issued "certificate"
        via a query string to both and 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 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


&lt;script type="text/javascript"&gt;
   jQuery.$foo = "bar";
       function () { alert("jQuery.$foo="+jQuery.$foo); }
jQuery.$foo = "quux";