]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/rpc/JsonpService.js.uncompressed.js
1 define("dojo/rpc/JsonpService", ["../main", "./RpcService", "../io/script"], function(dojo
) {
3 // dojo/rpc/JsonpService
8 dojo
.declare("dojo.rpc.JsonpService", dojo
.rpc
.RpcService
, {
10 // Generic JSONP service. Minimally extends RpcService to allow
11 // easy definition of nearly any JSONP style service. Example
12 // SMD files exist in dojox.data
14 constructor: function(args
, requiredArgs
){
17 dojo
.mixin(this.required
, requiredArgs
);
20 dojo
.forEach(this.required
, function(req
){
21 if(req
=="" || req
==undefined){
22 throw new Error("Required Service Argument not found: "+req
);
28 strictArgChecks
: false,
30 bind: function(method
, parameters
, deferredRequestHandler
, url
){
32 // JSONP bind method. Takes remote method, parameters,
33 // deferred, and a url, calls createRequest to make a JSON-RPC
34 // envelope and passes that off with bind.
36 // The name of the method we are calling
38 // The parameters we are passing off to the method
39 // deferredRequestHandler: deferred
40 // The Deferred object for this particular request
42 var def
= dojo
.io
.script
.get({
43 url
: url
||this.serviceUrl
,
44 callbackParamName
: this.callbackParamName
||"callback",
45 content
: this.createRequest(parameters
),
46 timeout
: this.timeout
,
50 def
.addCallbacks(this.resultCallback(deferredRequestHandler
), this.errorCallback(deferredRequestHandler
));
53 createRequest: function(parameters
){
57 // The array of parameters for this request;
59 var params
= (dojo
.isArrayLike(parameters
) && parameters
.length
==1) ?
61 dojo
.mixin(params
,this.required
);
66 return dojo
.rpc
.JsonpService
;