Debian Codegraph @

dojox/io/xhrScriptPlugin.js

raw symbols SCIP
1 define(["dojo/_base/kernel", "dojo/_base/window", "dojo/io/script", "dojox/io/xhrPlugins", "dojox/io/scriptFrame"], function(dojo, window, script, xhrPlugins, scriptFrame){
2 dojo.getObject("io.xhrScriptPlugin", true, dojox);
3
4 dojox.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
35 return dojox.io.xhrScriptPlugin;
36 });