为什么我收到的是 OPTIONS 请求而不是 GET 请求? [英] Why am I getting an OPTIONS request instead of a GET request?

查看:32
本文介绍了为什么我收到的是 OPTIONS 请求而不是 GET 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<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?

推荐答案

OPTIONS 来自 http://www.w3.org/TR/cors/http://metajack.im/2010/01/19/crossdomain-ajax-for-xmpp-http-binding-made-easy/ 了解更多信息

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆