reqwest请求api和约束(转载)
转自:https://www.oschina.net/p/reqwest
reqwest 用于浏览器异步HTTP请求。支持xmlHttpRequest, JSONP, CORS, 和 CommonJS约束。
API
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
reqwest('path/to/html', function (resp) { qwery('#content').html(resp)})reqwest({ url: 'path/to/html' , method: 'post' , data: { foo: 'bar', baz: 100 } , success: function (resp) { qwery('#content').html(resp) }})reqwest({ url: 'path/to/html' , method: 'get' , data: [ { name: 'foo', value: 'bar' }, { name: 'baz', value: 100 } ] , success: function (resp) { qwery('#content').html(resp) }})reqwest({ url: 'path/to/json' , type: 'json' , method: 'post' , error: function (err) { } , success: function (resp) { qwery('#content').html(resp.content) }})reqwest({ url: 'path/to/json' , type: 'json' , method: 'post' , contentType: 'application/json' , headers: { 'X-My-Custom-Header': 'SomethingImportant' } , error: function (err) { } , success: function (resp) { qwery('#content').html(resp.content) }})// Uses XMLHttpRequest2 credentialled requests (cookies, HTTP basic auth) if supportedreqwest({ url: 'path/to/json' , type: 'json' , method: 'post' , contentType: 'application/json' , crossOrigin: true , withCredentials: true , error: function (err) { } , success: function (resp) { qwery('#content').html(resp.content) }})reqwest({ url: 'path/to/data.jsonp?callback=?' , type: 'jsonp' , success: function (resp) { qwery('#content').html(resp.content) }})reqwest({ url: 'path/to/data.jsonp?foo=bar' , type: 'jsonp' , jsonpCallback: 'foo' , jsonpCallbackName: 'bar' , success: function (resp) { qwery('#content').html(resp.content) }})reqwest({ url: 'path/to/data.jsonp?foo=bar' , type: 'jsonp' , jsonpCallback: 'foo' , success: function (resp) { qwery('#content').html(resp.content) } , complete: function (resp) { qwery('#hide-this').hide() }}) |
约束
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
reqwest({ url: 'path/to/data.jsonp?foo=bar' , type: 'jsonp' , jsonpCallback: 'foo'}) .then(function (resp) { qwery('#content').html(resp.content) }, function (err, msg) { qwery('#errors').html(msg) }) .always(function (resp) { qwery('#hide-this').hide() })reqwest({ url: 'path/to/data.jsonp?foo=bar' , type: 'jsonp' , jsonpCallback: 'foo'}) .then(function (resp) { qwery('#content').html(resp.content) }) .fail(function (err, msg) { qwery('#errors').html(msg) }) .always(function (resp) { qwery('#hide-this').hide() })var r = reqwest({ url: 'path/to/data.jsonp?foo=bar' , type: 'jsonp' , jsonpCallback: 'foo' , success: function () { setTimeout(function () { r .then(function (resp) { qwery('#content').html(resp.content) }, function (err) { }) .always(function (resp) { qwery('#hide-this').hide() }) }, 15) }}) |
支持的浏览器
IE6+
Chrome 1+
Safari 3+
Firefox 1+
Opera
reqwest请求api和约束(转载)的更多相关文章
- [HTTP那些事]网络请求API
在Android上,原生API有两个,HttpUrlConnection和HttpClient,它们对封装Socket进行封装,让HTTP请求变得简单.这应该也算框架吧? 想象下,如果没有HttpUr ...
- 小程序前端防止重复点击请求api的简陋方法
upload: function () { let that = this; let {uploadFlag} = that.data; if (that.data.uploadFlag) { ret ...
- 关于ajax跨域请求API数据的一些问题
一般来说我们使用jquery的ajax来跨域请求API数据的时候每次请求,就只能请求一组数据,而且当我们再次点击发送ajax请求的时候,新请求的数据会覆盖掉原来的数据,那么如何每次在请求的数据的时候, ...
- 在线HTTP POST/GET模拟请求api接口http请求测试工具https://post.jsonin.com/
在线HTTP POST/GET模拟请求api接口http请求测试工具 在线POST/GET接口测试工具https://post.jsonin.com/ Json在线解析及格式化校验工具 https:/ ...
- ASP.NET Web Api 安全性(转载)
转载地址:http://www.cnblogs.com/fzrain/p/3552423.html 在Web Api中强制使用Https 我们可以在IIS级别配置整个Web Api来强制使用Https ...
- HTML5 Geolocation API工作原理[转载]
大家都知道,HTML5 Geolocation 可以使用 IP 地址.基于 Web 的数据库.无线网络连接和三角测量或 GPS 技术来确定经度和纬度. 问题: 在一个基于地理位置服务的个人业余项目(小 ...
- 跨域请求——WebClient通过get和post请求api
AJAX不可以实现跨域请求,经过特殊处理才行.一般后台可以通过WebClient实现跨域请求~ //get 请求 string url = string.Format("htt ...
- 微信小程序开发—快速掌握组件及API的方法---转载
微信小程序框架为开发者提供了一系列的组件和API接口. 组件主要完成小程序的视图部分,例如文字.图片显示.API主要完成逻辑功能,例如网络请求.数据存储.音视频播放控制,以及微信开放的微信登录.微信支 ...
- 第三篇、微信小程序-网络请求API
wx.request(OBJECT)发起的是https请求.一个微信小程序,同时只能有5个网络请求连接. OBJECT参数说明: 效果图: net.js Page({ data:{ result:{} ...
随机推荐
- Asp.net MVC5引用ExtJS6
摘要:VisualStuio2015 asp.net mvc如何引用ExtJS6,使用BundleConfig. 首先下载ExtJS6.0 gpl版.ExtJS有自己的程序框架,但我们需要asp.ne ...
- 报表控件NCreport教程:报表高级设计
本次文章中将讲解NCreport一些高级功能的应用,我们会先定义一个组,接下来会添加summary变量到示例报表中. 一.对summary添加变量 对于提供的数量和总量来说,变量是特殊的数值项,它们每 ...
- Make cnblogs mobile Compatible
Introduction 博客园的许多页面都是只支持PC的,没有手机端的,也没有手机端的app.每次查看都有放大了才能看清楚字体,手指和游泳似的,左右开弓,很不方便.还有上次我修改了theme之后,手 ...
- Centos7下Etcd集群搭建
一.简介 "A highly-available key value store for shared configuration and service discovery." ...
- 浅析Java.lang.ProcessBuilder类
最近由于工作需要把用户配置的Hive命令在Linux环境下执行,专门做了一个用户管理界面特地研究了这个不经常用得ProcessBuilder类.所以把自己的学习的资料总结一下. 一.概述 P ...
- dataRow转化为对象
对象类名useInfo,int,short,string,DateTime格式如下: userInfo.ErrorTimes = int.Parse(dataRow["ErrorTimes& ...
- JDBC的简单使用
JDBC的英文全称是: java Data Base Connectivity JDBC的主要作用: (是java数据库连接技术的简称)JDBC是由一系列连接(Conneation).SQL语句( ...
- ImportError: cannot import name 'check_arrays'
from sklearn.utils.validation import check_arrays 执行 from sklearn.utils.validation import check_arra ...
- easyui DataGrid 工具类之 TableUtil class
import java.lang.reflect.InvocationTargetException;import java.util.ArrayList;import java.util.HashM ...
- sql中文日期格式转换(xxxx年x月x日)
) set @dd='2014年10月1日' select replace(replace( replace(@dd,'日',''),'月','-'),'年','-') 别人的方法 )='2012年1 ...