jQuery的Ajax请求也越来越不取消发送 [英] jQuery Ajax requests are getting cancelled without being sent
问题描述
我试图挂钩脚本微软在全世界的望远镜应用程序。后者侦听端口5050的命令。它是在同一台机器上运行的浏览器(Chrome浏览器的权利,但据我可以告诉的行为是一样的与Firefox 7和IE 9)。
I am trying to hook up a script to Microsoft's World-Wide Telescope app. The latter listens on port 5050 for commands. It is running on the same machine as the browser (Chrome right now, but as far as I can tell the behavior is the same with Firefox 7 and IE 9).
我发送一个访问控制 - 允许 - 产地:*与原来的HTML文件头,以尽量消除XSS限制,我的问题
I am sending a "Access-Control-Allow-Origin: *" header with the original html file to try to eliminate XSS restrictions as my problem.
我的code进入污水处理如下:
My code to access WWT is as follows:
$.ajax({
type: 'POST',
url: url,
data: data,
crossDomain: true,
success: success,
dataType: dataType
});
URL在本例中为http://127.0.0.1:5050 / layerApi.aspx CMD =新的&放大器; ......(明明......是速记这里一些额外参数)
url in this case is "http://127.0.0.1:5050/layerApi.aspx?cmd=new&..." (obviously ... is shorthand here for some additional parameters).
看着在Chrome网络诊断,我可以看到这一点:
Looking at the network diagnostics in Chrome, I can see this:
Request URL:http://127.0.0.1:5050/layerApi.aspx?cmd=new&...
Request Headersview source
Accept:application/xml, text/xml, */*; q=0.01
Content-Type:application/x-www-form-urlencoded
Origin:http://gwheeler4
Referer:http://gwheeler4/conceptconnect.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1
该请求是走出去 - 我看WWT新建一个图层。但是,我没有得到一个回调。如果我再补充一点被调用错误回调,但jqXHR对象上的error属性仅仅是错误的状态为0。如果我看在Chrome网络请求之我见(取消)的状态,并没有任何反应
The request is going out - I see WWT make a new layer. However, I don't get a callback. If I add an error callback that gets called, but the error property on the jqXHR object is just "error" and status is 0. If I look at the network request in Chrome I see "(cancelled)" as the status and no response.
如果我采取相同的URL,并将其粘贴到新的浏览器选项卡上,我可以看到,响应是预期的XML。
If I take that same URL and paste it in a new browser tab, I can see that the response is the expected XML.
当然,这里不同的是,这是一个GET不是一个职位,但我试过,在我的剧本,并没有什么区别。
Of course, a difference here is that this is a GET not a POST, but I've tried that in my script and it makes no difference.
我是pretty的这个难倒并将AP preciate任何新的想法。
I'm pretty stumped by this and would appreciate any fresh ideas.
推荐答案
如果别人运行到这一点,我们有问题的是,我们在进行从链接Ajax请求,而不是$ P $被pventing链接紧随其后。所以,如果你这样做是在的onclick
属性,确保返回false;
以及
If anyone else runs into this, the issue we had was that we were making the ajax request from a link, and not preventing the link from being followed. So if you are doing this in an onclick
attribute, make sure to return false;
as well.
这篇关于jQuery的Ajax请求也越来越不取消发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!