javascript Jquery Ajax 调用返回 403 状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21979374/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jquery Ajax call return 403 status
提问by KRR
I have a jquery Ajax call implemented for keepalive the session, this keepAlive() method will call in every 20 mins
我有一个 jquery Ajax 调用来保持会话,这个 keepAlive() 方法将每 20 分钟调用一次
function keepAlive() {
$.ajax({ type: "POST",
url: "KeepAliveDummy.aspx", cache: false
});
}
This call is happen when the third party contents are loaded in to the frameset,
当第三方内容加载到框架集时会发生此调用,
I'm getting 403 http status (check via fiddler) on this request, Will this impact the end result of refresh the session time out?
我在此请求中收到 403 http 状态(通过提琴手检查),这会影响刷新会话超时的最终结果吗?
回答by Ashwini Verma
Since your question is about handling 403 error (Will this impact the end result of refresh the session time out?) rather what 403 is.
由于您的问题是关于处理 403 错误(这会影响刷新会话超时的最终结果吗?)而不是 403 是什么。
So, handle this error, you can log or notify.
所以,处理这个错误,你可以记录或通知。
$.ajax({
type: "POST",
url: "KeepAliveDummy.aspx",
success: function (response) {
//session refreshed
},
error: function (xhr, ajaxOptions, thrownError) {
if(xhr.status==403) {
//handle error
}
}
});
回答by Kai
about 403 :
关于 403 :
403 Forbidden The request was a valid request, but the server is refusing to respond to it.[2] Unlike a 401 Unauthorized response, authenticating will make no difference.[2]
403 Forbidden 该请求是一个有效的请求,但服务器拒绝响应它。 [2] 与 401 Unauthorized 响应不同,身份验证没有任何区别。 [2]
it needs you to authenticate (like login) first before do call ajax. 401 error requires authenticating header field when request but 403 doesn't.
在调用ajax之前,它需要您先进行身份验证(如登录)。401 错误需要在请求时验证标头字段,但 403 不需要。
check your server or contact who has responsibility for authentication.
检查您的服务器或负责身份验证的联系人。