var xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.open('post', 'http://localhost:20100/API/Wms/GetDeliveryDate', true);
// 请求超时的时间(单位:毫秒)
xhr.timeout = 3000;
// xhr.open('post', 'http://supply.zhglory.com.cn:9000/API/Wms/GetDeliveryDate', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// 允许跨域,服务端也要设置允许跨域
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
// 当请求成功完成时触发(服务器端是否发送错误都会触发,请求超时不会触发)
xhr.onload=function(){
if((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304){
debugger
console.log(`如果请求成功 xhr.status = ${xhr.status}`);
console.log(xhr.responseText);
}else{
debugger
console.log(`如果请求失败 xhr.status = ${xhr.status}`);
console.log(xhr.responseText);
}
}
// 请求超时的收货触发
xhr.ontimeout=function(e){
debugger
}
// 只有发生了网络层级别的异常才会触发此事件,对于应用层级别的异常,不会触发
xhr.onerror=function(e){
debugger
}
// 发送数据
xhr.send("asnNoAnLineNoes=['ASN19071400008|1']");
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!