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似乎总是遵循重定向.如何防止这种情况发生,并在不遵循重定向的情况下查看重定向?

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.

推荐答案

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 https://stackoverflow.com/a/2573589/965648

Jquery相关问答推荐

如何从 onclick div 属性检测 Javascript 中的 control+click?

如何滚动到jQuery中的元素?

javascript:无效(0); vs 返回 false vs preventDefault()

基于垂直滚动的jquery添加/删除类?

如何使用 jQuery 显示忙碌指示器?

jQuery淡出不显示无?

如何使用jQuery动态设置宽度和高度

我可以限制 JavaScript 中数组的长度吗?

$.each(selector) 和 $(selector).each() 有什么区别

如何更改 dropzone.js 中的默认文本?

使用带有 HTML 表格的 jQuery UI 可排序

获取跨域 iframe 的 DOM 内容

jQuery ajax (jsonp) 忽略超时并且不触发错误事件

.apply jQuery 函数是什么?

使用 AJAX 加载 Bootstrap 弹出内容.这可能吗?

更改 Eclipse 设置以忽略特定文件上的错误

用作 Google Chrome 书签

使用 jQuery 比较两个 Javascript 对象数组

detach()、hide() 和 remove() 之间的区别 - jQuery

.animate() 的回调被调用两次 jquery