我在使用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
发布评论