KO
|
EN
gitlite — search
Search
#python
#java
#python3
#arduino
#golang
#machine-learning
#rust
#html
#flask
#javascript
#seismology
#nodejs
jquery-jsonrpc2.0
★ 24
Open GitHub ↗
JSON RPC 2.0 for jQuery
Download README (.md)
Explore Similar Repositories
jslex
:
A lexical analyzer in JavaScript.
narwhal-lib
:
Narwhal's pure-JavaScript standard library as a package usable on other CommonJS engines.
relax
:
A library of simple modules for building web service wrappers.
tmjs
:
A Topic Maps engine written in JavaScript. It aims to be TMAPI 2.0 compliant and implements the Topic Maps - Data Model (TMDM).
mooj
:
jQuery-like syntax for Mootools.
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
jquery-jsonrpc2.0
?
Download (.md)
# 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://www.jsonrpc.org/specification> ## Usage ``` $.jsonrpc(rpcParams [, ajaxOpts]) .done(function(result) { // do something }) .fail(function(error) { // do something }); ``` Parameters Name | Type | Required | Description --- | --- | --- | --- rpcParams | Object or Array | YES | RPC Parameter. Array makes batch request. ajaxOpts | Object | NO | Set success or error callbacks. Other values (timeout, dataFilter, etc.) are passed to the $.ajax. ## Get Started ``` $ bower install jquery-jsonrpc2.0 ``` OR paste ``` <script type="test/javascript" src="https://cdn.rawgit.com/hagino3000/jquery-jsonrpc2.0/master/jquery.jsonrpc.js"></script> ``` ## Examples ``` $.jsonrpc.defaultUrl = '/rpc'; // Use promise $.jsonrpc({ method: 'createUser', params: {name: 'John Smith', userId: '1000'} }).done(function(result) { doSomething(result); }).fail(function(error) { console.info('code:', error.code); console.info('message:', error.message); console.info(error.data); }); // Set callback functions $.jsonrpc({ method: 'createUser', params: {name: 'John Smith', userId: '1000'} }, { success: function(result) { doSomething(result); }, error: function(error) { console.info('code:', error.code); console.info('message:', error.message); console.info(error.data); } }); ``` ### Batch Request Send several RPC Requests in one HTTP request. Always calls success callback. ``` $.jsonrpc.defaultUrl = '/rpc'; // Send 3 requests at once. $.jsonrpc([{ method: 'getEventStatus' }, { method: 'getUserStatus' }, { method: 'sendLoginStatus', params: {status: 'login'} }]).done(function(responses) { // Here comes all success and error results without notify request. // Results are sorted by RPC Id (the same as 1st arguments) results.forEach(function(response) { if (response.result) { doSomething(response.result); } else { doSomething(response.error); } }); }).fail(function(error) { // timeout }); ``` ### Notification ``` $.jsonrpc({ method: 'notify', params: {action: 'logout', userId: '1000'} }); ``` You can see more sample in test/public/test.js. Also server side code in test/app.js, written for node.js. ## Support jQuery > 1.7 ## License MIT