HTTP/RESTful 请求库 httpx.js
- 授权协议: MIT
- 开发语言: JavaScript HTML/CSS
- 操作系统: 跨平台
- 软件首页: https://github.com/pandao/httpx.js
软件介绍
httpx.js 是一个简单的 JavaScript HTTP/RESTful 请求库。
主要方法
-
GET
-
POST
-
PUT
-
PATCH
-
DELETE
-
Other
-
JSON
-
JSONP
-
getScript
兼容情况
-
Firefox 4.0+
-
Chrome 7+
-
IE 9+
-
Opera 11.60+
-
Safari 5.1.4+
使用方法
get|post|put|patch|delete|json(alias getJSON)(url, [data], [callback], [error]);
GET:
httpx.get("http://localhost/http-test/get.php?foo=Level1&bar=XHR&zh=中文", function(data) {
console.log(data, this);
}, function(method, url) {
console.error("Custom Error", method, url, this.status, this.statusText);
});
POST:
httpx.post("http://localhost/http-test/post.php?edfd=eedfd&dfsdf=ere", {
a : 12,
b : "bbbb",
c : 123489
}, function(data) {
console.log(data, this);
});
PUT:
httpx.put("http://localhost/http-test/put.php?edfd=eedfd&dfsdf=ere", {
a : 12,
b : "bbbb",
c : 123489
}, function(data) {
console.log(data, this);
});
DELETE:
httpx.delete("http://localhost/http-test/delete.php?edfd=eedfd&dfsdf=ere", {
a : 12,
b : "bbbb",
c : 123489
}, function(data) {
console.log(data, this);
});
JSON(getJSON):
// Alias getJSON(), like jQuery
httpx.json("http://localhost/http-test/get-json.php?temp="+(new Date).getTime(), {
test : 123
}, function(json) {
console.log("get json =>", json);
});
JSONP:
//jsonp(url, [data], [callback], [callbackName]); // callbackName for query string name
httpx.jsonp("http://192.168.1.2/http-test/jsonp.php?temp="+(new Date).getTime(), {
test : 123
}, function(json) {
console.log("jsonp =>", json);
}, "callback");
getScript:
httpx.getScript("http://192.168.1.2/http-test/test.js", function() {
test();
});
选项
{
async : true,
timeout : 3000,
method : "GET",
url : "",
data : "",
dataType : "text",
headers : {},
contentType : "text/plain; charset=UTF-8",
jsonp : "callback", // for query string
success : function() {},
error : function(method, url) {},
ontimeout : function(method, url) {}
}
httpx.request({
url : "http://localhost/http-test/head.php",
method : "HEAD", // Custom http method
headers : {}, // Custom http headers
success : function(data) {
console.log(data);
}
});
httpx.get({
url : "http://localhost/http-test/get.php?foo=bar",
headers : {
"xxxxxxx" : "xxxxx"
},
success : function(data) {
console.log(data);
}
});
httpx.post({
url : "http://localhost/http-test/post.php?foo=bar",
data : {
id : 123,
title : "xxxxx"
},
headers : {
"xxxxxxx" : "xxxxx"
},
success : function(data) {
console.log(data);
}
});
// put/patch/delete/json ...
重新定义团队:谷歌如何工作
拉兹洛·博克 / 宋伟 / 中信出版集团 / 2015-12-1 / CNY 56.00
谷歌首席人才官拉斯洛•博克权威力作,谷歌公开认可的谷歌高层作品,首度揭秘谷歌颠覆工业时代模式的人才和团队管理的核心法则,《纽约时报》畅销榜第一名,Business Insider 2015最佳商业书籍,谷歌的创造力就在于此! 编辑推荐! 1、 谷歌人才官首次公开谷歌人才和团队管理的核心秘籍 在谷歌执掌人事多年的拉斯洛•博克是人才和团队管理的顶级专家。他加入谷歌后,谷歌的员工数从六......一起来看看 《重新定义团队:谷歌如何工作》 这本书的介绍吧!
