Ajax和状态302

编程入门 行业动态 更新时间:2024-10-08 00:34:44
本文介绍了Ajax和状态302的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在使用AJAX的问题(和/或jQuery的AJAX)和状态302。

I'm having a problem with ajax (and/or jQuery ajax) and status 302.

这就是我想:

var xhr = new XMLHttpRequest(); xhr.open("GET", 'some_page_that_I_cant_change.php'); xhr.onreadystatechange = function(){ console.log(xhr.readyState, xhr.status); }; xhr.send(null);

在 some_page_that_I_cant_change.php 重定向到一个的.bin 与 302 code。我不想下载此文件,我只是想知道这个文件的路径。例如:

The some_page_that_I_cant_change.php redirects to a .bin with 302 code. I do not want to download this file, I just want know the path to the file. Example:

./some_page_that_I_cant_change.php ./path/to/bin/file.bin << I wan't only this path as string

问题是,Chrome会自动重定向到文件,瞒着我的路径,脚本。是否有解决方法吗?

The problem is that Chrome automatically redirects to the file, without telling me the path to script. Is there a workaround for this?

推荐答案

如果您使用的是HEAD请求,而不是GET请求,我怀疑会做你想做的。您应该只看到响应,没有响应主体(即没有.bin文件会下载)头。

If you use a HEAD request instead of a GET request, I suspect that will do what you want. You should only see headers in the response, no response body (i.e., no .bin will download).

更多推荐

Ajax和状态302

本文发布于:2023-10-10 18:08:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479338.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态   Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!