root / trunk / web / dojo / dojox / rpc / JsonRPC.js @ 9
History | View | Annotate | Download (1.03 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.rpc.JsonRPC"]){ |
9 |
dojo._hasResource["dojox.rpc.JsonRPC"]=true; |
10 |
dojo.provide("dojox.rpc.JsonRPC");
|
11 |
dojo.require("dojox.rpc.Service");
|
12 |
(function(){
|
13 |
function _1(_2){ |
14 |
return {serialize:function(_3,_4,_5,_6){ |
15 |
var d={id:this._requestId++,method:_4.name,params:_5}; |
16 |
if(_2){
|
17 |
d.jsonrpc=_2; |
18 |
} |
19 |
return {data:dojo.toJson(d),handleAs:"json",contentType:"application/json",transport:"POST"}; |
20 |
},deserialize:function(_7){ |
21 |
if("Error"==_7.name){ |
22 |
_7=dojo.fromJson(_7.responseText); |
23 |
} |
24 |
if(_7.error){
|
25 |
var e=new Error(_7.error.message||_7.error); |
26 |
e._rpcErrorObject=_7.error; |
27 |
return e;
|
28 |
} |
29 |
return _7.result;
|
30 |
}}; |
31 |
}; |
32 |
dojox.rpc.envelopeRegistry.register("JSON-RPC-1.0",function(_8){ |
33 |
return _8=="JSON-RPC-1.0"; |
34 |
},dojo.mixin({namedParams:false},_1())); |
35 |
dojox.rpc.envelopeRegistry.register("JSON-RPC-2.0",function(_9){ |
36 |
return _9=="JSON-RPC-2.0"; |
37 |
},_1("2.0"));
|
38 |
})(); |
39 |
} |