JQuery Rest客户端库

JQuery Rest

https://github.com/jpillora/jquery.rest/

Summary

A jQuery plugin for easy consumption of RESTful APIs

Downloads

File Size Report

Original: 10314 bytes.
Minified: 5920 bytes.
Gzipped:  1376 bytes.

Features

  • Simple
  • Uses jQuery Deferred for Asynchonous chaining
  • Basic Auth Support
  • Helpful Error Messages
  • Memory Cache
  • Cross-domain Requests with XDomain

 

 

DEMO

Basic Usage

  1. Create a client.
  2. Construct your API.
  3. Make requests.

First setup your page:

<!-- jQuery -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <!-- jQuery rest --> <script src="http://jpillora.com/jquery.rest/dist/1/jquery.rest.min.js"></script> <!-- WARNING: I advise not using this link, instead download and host this library on your own server as GitHub has download limits --> <script>  // Examples go here... </script>

Hello jquery.rest

var client = new $.RestClient('/rest/api/'); client.add('foo'); client.foo.read(); // GET /rest/api/foo/ client.foo.read(42); // GET /rest/api/foo/42/ client.foo.read('forty-two'); // GET /rest/api/foo/forty-two/

Retrieving Results (Uses jQuery's $.Deferred)

var client = new $.RestClient('/rest/api/'); client.add('foo'); var request = client.foo.read(); // GET /rest/api/foo/ request.done(function (data, textStatus, xhrObject){ alert('I have data: ' + data); }); // OR simply: client.foo.read().done(function (data){ alert('I have data: ' + data); });

 

 

更多功能和例子见:

https://github.com/jpillora/jquery.rest/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值