我想使用jQuery来获取URL,并明确检查它是否响应302重定向,但是不遵循重定向.
I want to use jQuery to GET a URL and explicitly check if it responded with a 302 redirect, but not follow the redirect.
jQuery的$.ajax似乎总是遵循重定向.如何防止这种情况,并在不遵循重定向的情况下看到重定向?
jQuery's $.ajax appears to always follow redirects. How can I prevent this, and see the redirect without following it?
标题为"jquery ajax redirect"的标题存在各种问题,但它们似乎都涉及实现其他目标,而不仅仅是直接检查服务器给出的状态.
There are various questions with titles like "jquery ajax redirect" but they all appear to involve accomplishing some other goal, rather than just directly checking the status that a server gives.
推荐答案AJAX请求永远没有机会不遵循重定向(即,它必须遵循重定向).可以在此答案中找到更多信息 stackoverflow/a/2573589/965648
The AJAX request never has the opportunity to NOT follow the redirect (i.e., it must follow the redirect). More information can be found in this answer stackoverflow/a/2573589/965648
更多推荐
在ajax请求中检测到重定向?
发布评论