结合以下各项的错误:jQuery 1.4,ajax/json,Firebug Lite和IE 8 [英] Bug with combination of: jQuery 1.4, ajax/json, Firebug Lite and IE 8

查看:148
本文介绍了结合以下各项的错误:jQuery 1.4,ajax/json,Firebug Lite和IE 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚得出的结论是,无论我尝试了什么,jQuery的ajax调用都无法在IE 8中使用JSON数据.我发现我可以使用jQuery 1.3.2库并解决了这个问题,但是1.4根本无法解决JSON ajax请求.即使返回的JSON数据是如此简单,也毫无疑问它的格式无效.例如:

I had just about concluded that jQuery's ajax calls wouldn't work with JSON data in IE 8, no matter what I tried. I found that I could use the jQuery 1.3.2 library and this fixed the problem, but 1.4 simply would not play ball with JSON ajax requests. Even when the JSON data returned was so simple that there was no question of it being in an invalid format. For example:

{"x":"a"}

这与我是否使用Java servlet返回JSON数据或简单的固定文本文件无关.不论dataType或contentType.不论GET与POST.无论我使用$ .ajax还是$ .getJSON.所有这些都可以在Firefox 3.6中使用.

This was regardless of whether I used a Java servlet to return the JSON data, or a simple, canned text file. Regardless of dataType or contentType. Regardless of GET vs POST. Regardless of whether I used $.ajax or $.getJSON. And it all works in Firefox 3.6.

然后我突然冒出了对Firebug Lite和IT WORKED的引用!突然,问题消失了.不管修改响应中的contentType(在servlet中)还是我在请求中指定的dataType,它都有效.

Then it dawned on me to take out the reference to Firebug Lite and IT WORKED! Suddenly the problem vanished. It worked regardless of tinkering with the contentType in the response (in the servlet that is), or of the dataType I specify in the request.

如果我再次链接到Firebug Lite,问题就会返回……即使我的代码从未真正使用过它.

The problem returns if I link to Firebug Lite again...even if my code never actually uses it.

有人见过这种行为吗?有人有解决方法或解决方法吗?我讨厌不得不停止使用Firebug Lite.感谢您的任何见解.同样,仅当您将jQuery 1.4,Firebug Lite,JSON数据和IE 8结合使用时,才会出现此问题.

Has anyone seen this kind of behavior, and does anyone have a fix or workaround? I'd hate to have to stop using Firebug Lite. Thanks for any insight. Again, the problem only occurs when you combine jQuery 1.4, Firebug Lite, JSON data, and IE 8.

这很重要,这是对servlet的ajax调用:

Here is the ajax call to a servlet, if it matters:

$.ajax({
 cache: false,
 url:"http://localhost:8080/Performance_Reporting/TestServlet",
 type:"GET",
 contentType: "application/json",
 dataType: "json",
 timeout:30000,
 success: function(d, status, req)
 {
  $("#result").text(d.x);
 },
 error: function(req, status, err)
 {
  $("#result").text(req.responseText);
 }
})

推荐答案

我实际上也看到了与纯HTML响应相同的问题.

I've actually seen the same problem with plain HTML responses, too.

这篇关于结合以下各项的错误:jQuery 1.4,ajax/json,Firebug Lite和IE 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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