chrome 模拟发送POST请求和GET请求

时间:2025-02-14 22:15:47
POST请求
var url = "http://ip地址:8080/test/?id=26323";
var params = {"billIds":["56141305725718528"],"billType":"VBNSC"}; 
var xhr = new XMLHttpRequest();
("POST", url, true);
("Content-Type", "application/json");
= function (e) {
if ( === 4) {
    if ( === 200) {
    ();
    } else {
    ();
    }
    }
};
((params));
= function (e) {
();
};
GET请求
var url = "http://IP:8080/testGet?id=235";
var xhr = new XMLHttpRequest();
("GET", url, true);
// ("Content-Type", "application/json");
= function (e) {
if ( === 4) {
    if ( === 200) {
    ();
    } else {
    ();
    }
    }
};
();
= function (e) {
();
};