谷歌浏览器发送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);
};



版权声明:本文为qq_38310244原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。