source: Dev/trunk/src/client/dojox/io/xhrScriptPlugin.js @ 536

Last change on this file since 536 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.4 KB
Line 
1define(["dojo/_base/kernel", "dojo/_base/window", "dojo/io/script", "dojox/io/xhrPlugins", "dojox/io/scriptFrame"], function(dojo, window, script, xhrPlugins, scriptFrame){
2dojo.getObject("io.xhrScriptPlugin", true, dojox);
3
4dojox.io.xhrScriptPlugin = function(/*String*/url, /*String*/callbackParamName, /*Function?*/httpAdapter){
5        // summary:
6        //              Adds the script transport (JSONP) as an XHR plugin for the given site. See
7        //              dojox.io.script for more information on the transport. Note, that JSONP
8        //              is *not* a secure transport, by loading data from a third-party site using JSONP
9        //              the site has full access to your JavaScript environment.
10        // url:
11        //              Url prefix of the site which can handle JSONP requests.
12        // httpAdapter:
13        //              This allows for adapting HTTP requests that could not otherwise be
14        //              sent with JSONP, so you can use a convention for headers and PUT/DELETE methods.
15        xhrPlugins.register(
16                "script",
17                function(method,args){
18                         return args.sync !== true &&
19                                (method == "GET" || httpAdapter) &&
20                                (args.url.substring(0,url.length) == url);
21                },
22                function(method,args,hasBody){
23                        var send = function(){
24                                args.callbackParamName = callbackParamName;
25                                if(dojo.body()){
26                                        args.frameDoc = "frame" + Math.random();
27                                }
28                                return script.get(args);
29                        };
30                        return (httpAdapter ? httpAdapter(send, true) : send)(method, args, hasBody); // use the JSONP transport
31                }
32        );
33};
34
35return dojox.io.xhrScriptPlugin;
36});
Note: See TracBrowser for help on using the repository browser.