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
- Create a client.
- Construct your API.
- 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/
出处:http://www.cnblogs.com/lightsong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
2017-01-07 LazyMan的Promise解法