https://github.com/outatime/jquery-jsonrpc
jQuery JSON-RPC Plugin.
https://github.com/outatime/jquery-jsonrpc
Last synced: 17 days ago
JSON representation
jQuery JSON-RPC Plugin.
- Host: GitHub
- URL: https://github.com/outatime/jquery-jsonrpc
- Owner: outaTiME
- Created: 2011-06-14T17:19:29.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2011-06-14T18:23:33.000Z (about 15 years ago)
- Last Synced: 2025-12-08T14:54:51.501Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 93.8 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
jQuery JSON-RPC Plugin
======================
A JSON-RPC 2.0 implementation for jQuery.
What is JSON-RPC?
-----------------
JSON-RPC is a lightweight remote procedure call protocol. It's designed to be simple!
Usage
-----
### Invocation
$.jsonrpc({
id: 1,
url: "foo",
method: "method",
params: {
// pass
},
success: function (response) {
// pass
},
fault: function (response, errordata) {
// pass
},
error: function (request, status, error) {
// pass
}
});
### Parameter detail
* `id`:
The request id (optional).
* `url`:
A string containing the URL to which the request is sent.
* `method`:
A String containing the name of the method to be invoked.
* `params`:
An object to pass as arguments to the method (optional).
* `success`:
A function to be called if the request succeeds (optional).
* `fault`:
A function to be called if the request succeeds (but with error response) (optional).
* `error`:
A function to be called if the request fails (optional).
Examples
--------
// A RPC call with named parameters
$.jsonrpc({
url: "/rpc",
method: "createUser",
params: {
name: "John Smith",
userId: 1000
},
success: function (response) {
// pass
},
fault: function (response, errordata) {
// pass
},
error: function (request, status, error) {
// pass
}
});
// A Notification
$.jsonrpc({
url: "/rpc",
method: "notify",
params: {
action: "logout",
userId: 1000
}
});
// A Notification using console to debug and with timeout set
$.jsonrpc({
url: "/rpc"
method: "notify",
params: {
action: "logout",
userId: 1000
},
timeout: 500
});