3

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?

2
  • 1
    Try parsing the html first. .append($.parseHTML(data)); Commented Apr 11, 2013 at 18:00
  • What do you want to achieve? Commented Apr 11, 2013 at 18:14

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

yes it true. IN IE8 if response is too large then ajax call is not working. to work with IE8 we have to reduce the content which we are getting from the ajax call.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.