travelping / jquery.jsonrpc

Yet another JSON-RPC plugin. JSON-RPC 2.0 and JSON-RPC over WebSocket Support

Home Page:http://plugins.jquery.com/project/jsonRpc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jQuery JSON-RPC Plugin

A JSON-RPC 2.0 implementation for jQuery.
JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol.
Read more in the <http://groups.google.com/group/json-rpc/web/json-rpc-2-0>

Usage:
  $.jsonrpc(url, data [, callbacks] [, debug]);

  where data = {method:'methodname', params:['positional', 'parameters']}
  or data = {method:'complexmethod', params:{named:'parameters', works:'too!'}}
  and callbacks = {success: successFunc, fault: faultFunc, error: errorFunc}

  Setting no callback produces a JSON-RPC Notification.
  'data' accepts 'timeout' keyword too, who sets the $.ajax request timeout.
  Setting 'debug' to true prints responses to Firebug's console.info

Examples:
  // A RPC call with named parameters
  $.jsonrpc('/rpc', {
    method : 'createUser',
    params : {name : 'John Smith', userId : '1000'}
  }, {
    success : doSomething(response),
    fault : handleFault(response, errordata),
    error : handleError(request, status, error);
  });

  // A Notification 
  $.jsonrpc('/rpc', {
    method : 'notify',
    params : {action : 'logout', userId : '1000'}
  });

  // A Notification using console to debug and with timeout set
  $.jsonrpc('/rpc', {
    method : 'notify',
    params : {action : 'logout', userId : '1000'},
    debug : true,
    timeout : 500,
  });

About

Yet another JSON-RPC plugin. JSON-RPC 2.0 and JSON-RPC over WebSocket Support

http://plugins.jquery.com/project/jsonRpc

License:MIT License