summaryrefslogtreecommitdiff
path: root/lib/dojo/rpc/JsonpService.js.uncompressed.js
diff options
context:
space:
mode:
authorRichard Beales <[email protected]>2013-03-18 07:32:01 +0000
committerRichard Beales <[email protected]>2013-03-18 07:32:01 +0000
commit7c97d17aaf373339a8bcd917ad59ca6018148f0d (patch)
tree5a3c04f0f9529be392c1263d3feb75806eb43797 /lib/dojo/rpc/JsonpService.js.uncompressed.js
parent70db7424e7068701e60cc5bcdfe8f858be508179 (diff)
parentc670a80ddd9b03bd4ea6d940a9ed682fd26248d7 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'lib/dojo/rpc/JsonpService.js.uncompressed.js')
-rw-r--r--lib/dojo/rpc/JsonpService.js.uncompressed.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/dojo/rpc/JsonpService.js.uncompressed.js b/lib/dojo/rpc/JsonpService.js.uncompressed.js
new file mode 100644
index 000000000..673a68c37
--- /dev/null
+++ b/lib/dojo/rpc/JsonpService.js.uncompressed.js
@@ -0,0 +1,66 @@
+define("dojo/rpc/JsonpService", [
+ "../_base/array", "../_base/declare", "../_base/lang", "./RpcService", "../io/script"],
+ function(array, declare, lang, RpcService, script){
+
+// module:
+// dojo/rpc/JsonpService
+
+return declare("dojo.rpc.JsonpService", RpcService, {
+ // summary:
+ // Generic JSONP service. Minimally extends RpcService to allow
+ // easy definition of nearly any JSONP style service. Example
+ // SMD files exist in dojox.data
+
+ constructor: function(args, requiredArgs){
+ if(this.required){
+ if(requiredArgs){
+ lang.mixin(this.required, requiredArgs);
+ }
+
+ array.forEach(this.required, function(req){
+ if(req=="" || req==undefined){
+ throw new Error("Required Service Argument not found: "+req);
+ }
+ });
+ }
+ },
+
+ strictArgChecks: false,
+
+ bind: function(method, parameters, deferredRequestHandler, url){
+ // summary:
+ // JSONP bind method. Takes remote method, parameters,
+ // deferred, and a url, calls createRequest to make a JSON-RPC
+ // envelope and passes that off with bind.
+ // method: string
+ // The name of the method we are calling
+ // parameters: array
+ // The parameters we are passing off to the method
+ // deferredRequestHandler: deferred
+ // The Deferred object for this particular request
+
+ var def = script.get({
+ url: url||this.serviceUrl,
+ callbackParamName: this.callbackParamName||"callback",
+ content: this.createRequest(parameters),
+ timeout: this.timeout,
+ handleAs: "json",
+ preventCache: true
+ });
+ def.addCallbacks(this.resultCallback(deferredRequestHandler), this.errorCallback(deferredRequestHandler));
+ },
+
+ createRequest: function(parameters){
+ // summary:
+ // create a JSONP req
+ // params: array
+ // The array of parameters for this request;
+
+ var params = (lang.isArrayLike(parameters) && parameters.length==1) ?
+ parameters[0] : {};
+ lang.mixin(params,this.required);
+ return params;
+ }
+});
+
+});