jQuery.ajax 类型:发布到未在 IE 中启动的 ashx 文件。在 FF、Chrome 和 Safari 中运行良好
这是我向堆栈提出的第一个问题。
jQuery.ajax 类型:发布到未在 IE 中启动的 ashx 文件。在 FF、Chrome 和 Safari 中工作正常
代码如下:
$.ajax({
type: "Post",
url: "http://[ ... ]loguserdata.ashx?" + dataString,
data: "",
cache: "false",
contentType: "text/plain",
success: function(msg){
//alert( "Data Saved: " + msg );
}
});
by 在 FF 等中工作正常。我的意思是调用 ashx 文件并记录信息。 我可以在 fiddler、firebug 和 chrome 等价物中看到 ajax 调用。
但在 IE9 或 IE 兼容模式下似乎没有发生这种情况。
我可以获得上面代码的多个版本,以便在其他浏览器中工作。包括 $('#result').load( ...
但在 IE 中没有任何作用
,顺便说一句,在 IE 本地工作正常。
哦,我不会对任何返回值给出任何错误的看法.
这不是缓存问题。我在 querystring
的末尾添加了一个 date=getTime()
。类似的东西fname=john&lname=doedy
编辑:我已经解决了这个问题,明天有时间我会发布一个完整的答案。
this is my first question to the stack.
jQuery.ajax type: Post to an ashx file not being initiated in IE. works fine in FF, Chrome, and 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.
I can see the ajax call in fiddler, firebug and chrome's equivalent.
but there doesn't seem to be jackchit happening in IE9 or in IE compatibility mode.
I can get several versions of the code above to work in the other browsers. Including a $('#result').load( ...
but NOTHING works in IE
btw, works fine locally in 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
.
querystring (dataString)
looks something like fname=john&lname=doedy
EDIT: I have solved this issue. I will post a thorough answer tomorrow when I have time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
长篇故事被删减:
您不能执行 XMLHttpRequest 跨域。使用 jQuery 的 getJSON 方法和查询字符串参数 &callback=?添加到网址。我相信这会将数据类型转换为 JSONP。
这里有一些帮助我解决这个问题的链接。
XMLHttpRequest 无法使用 jQuery 加载 URL
http://api.jquery.com/jQuery.getJSON/ 请参阅下面的摘录
http://api.jquery.com/jQuery.ajax/ 请参阅下面的摘录
Long story truncated:
You can't do a XMLHttpRequest crossdomain. Use jQuery's getJSON method with the querystring parameter &callback=? added to the url. This I believe converts the datatype to JSONP.
Here are a few links that helped me solve this.
XMLHttpRequest cannot load an URL with jQuery
http://api.jquery.com/jQuery.getJSON/ see excerpt below
http://api.jquery.com/jQuery.ajax/ see excerpt below
由于您没有发送 POST 数据,请尝试以下操作:
Try this since you aren't sending POST data:
检查您的 IE 安全性,因为它在本地工作。我猜想 locahost 上的文件有更多的权限。
编辑:
IE9阻止跨域ajax调用,Opera浏览器也是如此。
对于 IE9,您可以阅读这篇文章 ,寻求解决方法。建议使用 XDR (XDomainRequest) 而不是通常的 XMLHttpRequest。
Check your IE security, since it's work locally. I guess that files on the locahost have more privileges.
Edit:
IE9 prevent doing cross-domain ajax call, Opera browser too.
For IE9 you can read this article, for a workaround. It suggest to use XDR (XDomainRequest) instead of the usual XMLHttpRequest.