]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/rpc/JsonpService.js.uncompressed.js
1 define("dojo/rpc/JsonpService", [
2 "../_base/array", "../_base/declare", "../_base/lang", "./RpcService", "../io/script"],
3 function(array
, declare
, lang
, RpcService
, script
){
6 // dojo/rpc/JsonpService
8 return declare("dojo.rpc.JsonpService", 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 lang
.mixin(this.required
, requiredArgs
);
20 array
.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
= 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
= (lang
.isArrayLike(parameters
) && parameters
.length
==1) ?
61 lang
.mixin(params
,this.required
);