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

F12打开Console输入以下代码:

POST请求

var url = "http://ip地址:8080/test/?id=26323";

var params = {"billIds":"56141305725718528","billType":"VBNSC"};

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);

};

GET请求

var url = "http://IP:8080/testGet?id=235";

var xhr = new XMLHttpRequest();

xhr.open("GET", 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();

xhr.onerror = function (e) {

console.error(xhr.statusText);

};

相关推荐
kTR2hD1qb13 分钟前
Claude Code Skill的介绍与使用
java·前端·数据库·人工智能
修己xj1 小时前
打造专属博文封面神器:一个开源免费的博文封面生成器ThisCover
前端
kyriewen1 小时前
面试8家前端岗位后,我发现了一个残酷的事实:AI不是加分项,是门槛
前端·javascript·面试
Fighting_p1 小时前
【面试 - el-select问题及解决】wujie 微前端下子系统 el-select 多选 filterable 过滤失效
前端
吃口巧乐兹1 小时前
AI 全栈时代,为什么要服务端使用 NestJs
前端
yingyima2 小时前
Redis 延迟任务队列:凌晨3点服务器报警的救星
前端
weiggle2 小时前
第三篇:可组合函数(Composable)——Compose 的基石
android·前端
前端环境观察室2 小时前
别只看 task success:AI Agent 浏览器自动化真正要补的是环境证据链
前端·后端
huakoh2 小时前
LangChain 实战:用混合检索啃下 1000 页 PDF,搭一个长文档问答 Agent
前端
Dazer0072 小时前
Edge 浏览器绕过 HTTPS 证书错误
前端·https·edge