开发者

JSON RPC in jqGrid

开发者 https://www.devze.com 2023-02-11 03:35 出处:网络
I am developing a web application which communicates to/from a server using JSON. I use var jsonStr = \'{ name: \"Rob\", time: \"2pm\" }\';

I am developing a web application which communicates to/from a server using JSON. I use

var jsonStr = '{ name: "Rob", time: "2pm" }';
jQuery("#name").jqGrid({
    type : "POST",
    url:'ControllerServlet?jsonData='+jsonStr,
    datatype: "json",

to pass data to server as JSON string, parse it in server, pr开发者_C百科ocess it and send a JSON back which is displayed in the jqGrid.

This works for me, but I wonder what is the role of JSON-RPC; I read that it is used for remote calls. Is there any advantage in using JSON-RPC instead of using the above way to invoke servlet? How can I use JSON-RPC to do the same action?


As the website states, JSON-RPC is a remote procedure call protocol specification using JSON. It is therefore a specification to call remote methods/procedures on a server similar to XML-RPC or Java's RMI. Both JSON-RPC and XML-RPC can use HTTP as the underlying transport protocol but can also work with others.

On the other hand jqGrid and in general Ajax usually uses HTTP (ideally RESTful) requests to fetch or transfer direct representations of e.g. JSON or XML encoded data. By now this is the preferred way in JavaScript development (comparison of REST vs XML-RPC is a nice read and applies to JSON-RPC as well).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号