jQuery的获取IE不读HTML的响应数据 [英] jQuery GET not reading HTML response data in IE

查看:112
本文介绍了jQuery的获取IE不读HTML的响应数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了pretty的简单Ajax调用使用jQuery(在Word preSS) - 使用GET获取页面的内容,然后读取响应转换成一个jQuery对象。这除了IE8(不关心IE6 / 7相关的code每一个浏览器工作正常,等同于我所使用previous网站,所有这些工作在IE8的下面是code:

I'm doing a pretty simply ajax call using jQuery (in Wordpress) - using GET to fetch the contents of a page, then reading the response into a jQuery object. This works fine in every browser except IE8 (not concerned about IE6/7. The relevant code is identical to what I have used in previous sites, all of which work in IE8. Here's the code:

var ajax_params = {
url: relative_url,
type: 'GET',
dataType: 'html',
data: {},

success: function(data, textStatus, xhr) {

     // create jquery element from html string
    data = $('<div/>').append(data);

    pre($(data).find('#content'));
    pre($('#content'));

    plugin.replace_content(data, relative_url);

},

};

plugin.ajax_call = $.ajax(ajax_params);

在pre()函数只是调用CONSOLE.LOG,而我用Firebug精简版在IE8调试。我已经确定Ajax调用的工作,并正在在数据变量成功返回请求页面的HTML。它变得挂上数据= $('&LT; D​​IV /&GT;)。追加(数据),其中结果是一个空的div。正如我所说的,这个确切的code适用于其他网站,所以我在无法解释这一点。我已经降级了jQuery版本1.8.3以匹配是在其他网站也没有用。

The pre() functions are just calls to console.log, and I'm using firebug lite in IE8 to debug. I've determined that the ajax call is working, and the HTML of the requested page is being returned successfully in the data variable. It's getting hung up on data = $('<div/>').append(data), where the result is an empty div. As I said, this exact code works on other sites, so I'm at a loss to explain this. I've downgraded the jQuery version to 1.8.3 to match what is on the other sites to no avail.

任何想法?

推荐答案

我们想通了这个问题:它是一个记忆的问题,所造成的Ajax响应是太大的IE浏览器解析。这可以解释为什么在其他网站上完全相同的方法处理。我们通过剥离出尽可能多地从响应HTML固定它。另一个解决方案是将所述响应数据分割成块,并进行多个Ajax请求。

We figured out the problem: it was a memory issue, caused by the ajax response being too large for IE to parse. This would explain why the exact same method on other sites worked. We fixed it by stripping out as much as possible from the response html. Another solution would be to split the response data into chunks and make multiple ajax requests.

这篇关于jQuery的获取IE不读HTML的响应数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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