Login Register

Alternate Transports

Script request/JSONP (dojo.io.script)

To make an IO call using a script tag (for instance, for cross-domain JSONP calls), dojo.require("dojo.io.script"), and use:
  • dojo.io.script.get()
Specific arguments for dojo.io.script calls:
  • callbackParamName: "". String. The URL parameter name that indicates the JSONP callback string. For instance, when using Yahoo JSONP calls it is normally, callbackParamName: "callback". For AOL JSONP calls it is normally callbackParamName: "c".
  • checkString: "". String. A string of JavaScript that when evaluated like so: "typeof(" + checkString + ") != 'undefined'" being true means that the script fetched has been loaded. Do not use this if doing a JSONP type of call (use callbackParamName instead).
"handleAs" is NOT applicable to dojo.io.script.get() calls, since it is implied by the usage of "callbackParamName" (response will be a JSONP call returning JSON) or "checkString" (response is pure JavaScript defined in the body of the script that was attached).

IFrame requests (dojo.io.iframe)

To send an IO call using an IFrame (for instance, to upload files), dojo.require("dojo.io.iframe"), and use:
// gather all parameters from a form
dojo.io.iframe.send({
    form: "idOfForm",
    load: function(data){
         console.debug(data); // successful response
    }
});
// pass in all of the parameters manually
dojo.io.iframe.send({
    method: "GET",
    url: "iframeHandler.php",
    content: {
        param1: "la dee dah",
        param2: "my poor electrons!",
    },
    load: function(data){
         console.debug(data); // successful response
    }
});
Specific arguments for dojo.io.iframe calls:
  • method: "POST". What type of HTTP method to use for the request. Valid values are "POST" (default) or "GET".
  • handleAs: Valid values are text, html, javascript, and json. IMPORTANT: For all values EXCEPT html, The server response should be an HTML file with a textarea element. The response data should be inside the textarea element. Using an HTML document the only reliable, cross-browser way this transport can know when the response has loaded. For the text/html mimetype, just return a normal HTML document. NOTE: text/xml or any other XML type is NOT supported by this transport.

Documentation for dojo.script.io

There is some documentation for the dojo.script.io API in the migration doc here: http://dojotoolkit.org/book/dojo-porting-guide-0-4-x-0-9/io-transports-a...