Creates a JSON request using script tag injection and handles the callbacks for you.
new Request.JSONP(options);
new Request.JSONP({ url: 'http://api.cnet.com/restApi/v1.0/techProductSearch', data: { partTag: 'mtvo', iod: 'hlPrice', viewType: 'json', results: '100', query: 'ipod' }, onComplete: myFunction.bind(someObject) }).send();
The above example would generate this url:
http://api.cnet.com/restApi/v1.0/techProductSearch?partTag=mtvo&iod=hlPrice&viewType=json&results=100&query=ipod&callback=Request.JSONP.requests[0].handleResults&
It would embed a script tag (in the head of the document) with this url and, when it loaded, execute the "myFunction" callback defined.
Request.JSONP logs I/O operations to MooTools.log, which is a function that simply passes arguments into an array called MooTools.logged. You can redefine MooTools.log so that I/O operations show up in your preferred logger (like Firebug). Until you redefine it, log messages are cashed in the MooTools.logged array so that you can retrieve any messages already logged before you remap the method. For example, you might do this:
MooTools.log = console.log.bind(console); //then dump any existing logs to the console: MooTools.logged.each(function(log){ console.log.apply(console, log); });
Executes the JSON request.
myJsonP.send([options]);
Executes the JSON request.
myJsonP.send();
This documentation is released under a Attribution-NonCommercial-ShareAlike 3.0 License.