Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery GET not reading HTML response data in IE

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);

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.

Any ideas?

like image 722
briteweb Avatar asked Jan 31 '26 04:01

briteweb


1 Answers

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.

like image 93
briteweb Avatar answered Feb 01 '26 18:02

briteweb