Toggle navigation
亻中 阝日
社区
VA伐木累
Proxy
JSON
BASE64
MyGit
登录
注册
×
登录
邮箱
密码
忘记密码?
原生JS发送POST请求
•发布于
•作者
liuzy
•867 次浏览
•来自
技术
```js // 原生JS发送POST请求 function post(path, json, cb) { var xhr = new XMLHttpRequest(); xhr.setRequestHeader("Content-type","application/json;charset=UTF-8"); xhr.open('post', path); xhr.send(JSON.stringify(json)); xhr.onreadystatechange = function () { if (xhr.readyState == 4) { if (xhr.status == 200) { var res = JSON.parse(xhr.responseText); if (res.code == '200') { cb(res, xhr); } else { alert(res.msg); } } else { console.log('xhr error', xhr.status) console.log(xhr.responseText); } } }; } ```
0 回复
作者
liuzy
积分: 841
“ 黑眼圈圈男 ”
无人回复话题
SonarQube 9.4 + PostgreSQL
shell倒计时
日常网络巧技
使用ssh创建socks5代理服务
NodeJS集群demo
作者其他话题
SonarQube 9.4 + PostgreSQL
shell倒计时
日常网络巧技
使用ssh创建socks5代理服务
NodeJS集群demo
回到顶部
友情链接:
JFinal
©2015 Powered by
jfinalbbs
沪ICP备15012258号