我想检查一个页面是否返回状态码401.这是可能吗?
这里是我的尝试,但它只返回0。
$.ajax({ url: "http://my-ip/test/test.PHP",data: {},complete: function(xhr,statusText){ alert(xhr.status); } });
解决方法
这是可能与jQuery $ .ajax()方法
$.ajax(serverUrl,{ type: Outageviewmodel.Id() == 0 ? "POST" : "PUT",data: dataToSave,statusCode: { 200: function (response) { alert('1'); AfterSavedAll(); },201: function (response) { alert('1'); AfterSavedAll(); },400: function (response) { alert('1'); bootBox.alert('<span style="color:Red;">Error While Saving Outage Entry Please Check</span>',function () { }); },404: function (response) { alert('1'); bootBox.alert('<span style="color:Red;">Error While Saving Outage Entry Please Check</span>',function () { }); } },success: function () { alert('1'); },});
原文地址:https://www.jb51.cc/jquery/185464.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。