为什么我收到OPTIONS请求而不是GET请求? [英] Why am I getting an OPTIONS request instead of a GET request?
问题描述
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
<script>
$.get("http://example.com/", function(data) {
alert(data);
});
</script>
它对该URL进行OPTIONS请求,然后永远不调用回调函数.
it does an OPTIONS request to that URL, and then the callback is never called with anything.
当它不是跨网域时,就可以正常工作.
When it isn't cross domain, it works fine.
jQuery是否应该仅使用<script>
节点进行调用,然后在加载时进行回调?我知道我将无法获得结果(因为它是跨域的),但是没关系;我只想打通电话.这是一个错误,还是我做错了什么?
Shouldn't jQuery just make the call with a <script>
node and then do the callback when its loaded? I understand that I won't be able to get the result (since it is cross domain), but that's OK; I just want the call to go through. Is this a bug, or am I doing something wrong?
推荐答案
选项来自 http://www.w3.org/TR/cors/参见
The OPTIONS is from http://www.w3.org/TR/cors/ See http://metajack.im/2010/01/19/crossdomain-ajax-for-xmpp-http-binding-made-easy/ for a bit more info
这篇关于为什么我收到OPTIONS请求而不是GET请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!