谷歌浏览器发送POST请求

使用谷歌浏览器发送POST请求

  1. F12打开控制台
  2. 打开console
  3. 输入以下代码并回车
var url = "http://localhost:8080/test/test";
var params = {"billIds":["56141305725718528"],"billType":"VBNSC"}; //此为json格式的参数
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onload = function (e) {
if (xhr.readyState === 4) {if (xhr.status === 200) {console.log(xhr.responseText);} else {console.error(xhr.statusText);}}
};
xhr.send(JSON.stringify(params));
xhr.onerror = function (e) {
console.error(xhr.statusText);
};


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部