简体   繁体   English

jQuery.ajax类型:发布到IE中未初始化的ashx文件。 在FF,Chrome和Safari中正常运行

[英]jQuery.ajax type: Post to an ashx file not being initiated in IE. works fine in FF, Chrome, and Safari

this is my first question to the stack. 这是我的第一个问题。

jQuery.ajax type: Post to an ashx file not being initiated in IE. jQuery.ajax类型:发布到IE中未初始化的ashx文件。 works fine in FF, Chrome, and Safari 在FF,Chrome和Safari中正常运行

Code below: 代码如下:

$.ajax({
    type: "Post",
        url: "http://[ ... ]loguserdata.ashx?" + dataString,
        data: "",
        cache: "false",
        contentType: "text/plain",
        success: function(msg){
            //alert( "Data Saved: " + msg );
        }
});

by works fine in FF, etc. I mean the ashx file is called and info is logged. 通过在FF等中正常工作,我的意思是调用了ashx文件并记录了信息。 I can see the ajax call in fiddler, firebug and chrome's equivalent. 我可以在小提琴手,firebug和chrome的等效工具中看到ajax调用。

but there doesn't seem to be jackchit happening in IE9 or in IE compatibility mode. 但是在IE9或IE兼容模式下似乎没有发生困境。

I can get several versions of the code above to work in the other browsers. 我可以得到上面代码的多个版本,以便在其他浏览器中工作。 Including a $('#result').load( ... 包括$('#result').load( ...

but NOTHING works in IE 但没什么可在IE中使用

btw, works fine locally in IE. 顺便说一句,在IE中可以在本地正常工作。

oh, and I don't give a diddly poo about any return value. 哦,关于任何返回值,我也不会给任何疑问。

and it's not a cache issue. 这不是缓存问题。 I have a date=getTime() tacked onto the end of the querystring . 我有一个date=getTime()附加到querystring的末尾。

querystring (dataString) looks something like fname=john&lname=doedy querystring (dataString)看起来像fname=john&lname=doedy

EDIT: I have solved this issue. 编辑:我已经解决了这个问题。 I will post a thorough answer tomorrow when I have time. 明天我有时间的时候,我会发表一个详尽的答案。

Long story truncated: You can't do a XMLHttpRequest crossdomain. 长话短说:您不能执行XMLHttpRequest跨域。 Use jQuery's getJSON method with the querystring parameter &callback=? 使用jQuery的getJSON方法和querystring参数&callback =? added to the url. 添加到网址。 This I believe converts the datatype to JSONP. 我相信这会将数据类型转换为JSONP。

 var url = 'http://handlers.flowauto.com/eprice/loguserdata.ashx?fname=jim&callback=?';
        $.getJSON(url, function(data) {
            // do some stuff
        });

Here are a few links that helped me solve this. 这里有一些链接可以帮助我解决这个问题。

XMLHttpRequest cannot load an URL with jQuery XMLHttpRequest无法使用jQuery加载URL

http://api.jquery.com/jQuery.getJSON/ see excerpt below http://api.jquery.com/jQuery.getJSON/参见下面的摘录

JSONP If the URL includes the string "callback=?" JSONP如果URL包含字符串“ callback =?” (or similar, as defined by the server-side API), the request is treated as JSONP instead. (或类似,由服务器端API定义),该请求将被视为JSONP。 See the discussion of the jsonp data type in $.ajax() for more details. 有关更多详细信息,请参见$ .ajax()中有关jsonp数据类型的讨论。

http://api.jquery.com/jQuery.ajax/ see excerpt below http://api.jquery.com/jQuery.ajax/参见下面的摘录

Additional Notes: Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; 附加说明:由于浏览器的安全性限制,大多数“ Ajax”请求都受相同的原始策略约束; the request can not successfully retrieve data from a different domain, subdomain, or protocol. 该请求无法成功从其他域,子域或协议检索数据。 Script and JSONP requests are not subject to the same origin policy restrictions. 脚本和JSONP请求不受相同的原始策略限制。

Check your IE security, since it's work locally. 检查IE安全性,因为它在本地工作。 I guess that files on the locahost have more privileges. 我想locahost上的文件有更多特权。

Edit: 编辑:

IE9 prevent doing cross-domain ajax call, Opera browser too. IE9也会阻止跨域Ajax调用,Opera浏览器也是如此。 For IE9 you can read this article , for a workaround. 对于IE9,您可以阅读本文 ,了解解决方法。 It suggest to use XDR (XDomainRequest) instead of the usual XMLHttpRequest. 建议使用XDR(XDomainRequest)代替通常的XMLHttpRequest。

Try this since you aren't sending POST data: 尝试此操作,因为您不发送POST数据:

$.ajax({
    type: "GET",
        url: "http://[ ... ]loguserdata.ashx?" + dataString,        
        cache: "false",
        contentType: "text/plain",
        success: function(msg){
            //alert( "Data Saved: " + msg );
        }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery ajax发布在IE,FF,Chrome中正常运行,但在Safari中无法正常运行 - jquery ajax post works fine in IE, FF, Chrome but not Safari jQuery加载不适用于IE 9(在FF,Chrome和Safari上正常运行) - jQuery load does not work on IE 9 ( works fine on FF, Chrome and Safari) 为什么我的jQuery无法在IE上运行(在Safari,Chrome和FF中可以正常工作)? - Why my jQuery is not working on IE (works fine in Safari, Chrome and FF)? <a href doesn't fire after .Click jquery function call in IE. Works fine with Chrome and FF - <a href doesn't fire after .Click jquery function call in IE. Works fine with Chrome and FF jQuery AJAX发布请求不适用于IE或FF-在Chrome中正常运行 - JQuery AJAX Post request doesn't work in IE or FF - Works fine in Chrome jQuery Ajax在IE 6/7/8中不起作用,在FF / Safari / Chrome中工作 - jQuery Ajax not working in IE 6/7/8, works in FF/Safari/Chrome JavaScript JQuery Ajax问题:POST在Firefox,IE,Safari和Chrome中无法正常工作 - JavaScript JQuery Ajax Issue: POST Works fine in Firefox, IE, Safari but not Chrome jQuery $ .ajax回调可用于FF和Safari,但不适用于IE - JQuery $.ajax callback works in FF and Safari, but not IE Javascript / jQuery无法在Firefox,Safari和IE中运行。 精通Opera和Chrome - Javascript/jQuery not working in Firefox, Safari and IE. Fine in Opera and Chrome jQuery ajax()或load()在IE中返回不完整的响应。 在Chrome中正常运行 - JQuery ajax(), or load() return incomplete response in IE. Works fine in Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM