Sha256: e587935fc4163459d1813c017489db8e6bc6831bf3f3d8ece92e04c3b98554e9

Contents?: true

Size: 1.89 KB

Versions: 11

Compression:

Stored size: 1.89 KB

Contents

dojo.provide("dojo.rpc.JsonpService");
dojo.require("dojo.rpc.RpcService");
dojo.require("dojo.io.script");

dojo.declare("dojo.rpc.JsonpService", dojo.rpc.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){
				dojo.mixin(this.required, requiredArgs);
			}

			dojo.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 = dojo.io.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 = (dojo.isArrayLike(parameters) && parameters.length==1) ?
				parameters[0] : {};
		dojo.mixin(params,this.required);
		return params;
	}
});

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
dojo_src-1.5.0 dojo/dojo/rpc/JsonpService.js
dojo_src-1.4.3 dojo/dojo/rpc/JsonpService.js
dojo_src-1.4.102 dojo/dojo/rpc/JsonpService.js
dojo-pkg-1.132.0 data/dojo-release-1.3.2-src/dojo/rpc/JsonpService.js
dojo-pkg-1.111.0 data/dojo-release-1.1.1-src/dojo/rpc/JsonpService.js
dojo-pkg-1.120.0 data/dojo-release-1.2.0-src/dojo/rpc/JsonpService.js
dojo-pkg-1.121.0 data/dojo-release-1.2.1-src/dojo/rpc/JsonpService.js
dojo-pkg-1.122.0 data/dojo-release-1.2.2-src/dojo/rpc/JsonpService.js
dojo-pkg-1.123.0 data/dojo-release-1.2.3-src/dojo/rpc/JsonpService.js
dojo-pkg-1.130.0 data/dojo-release-1.3.0-src/dojo/rpc/JsonpService.js
dojo-pkg-1.131.0 data/dojo-release-1.3.1-src/dojo/rpc/JsonpService.js