Adam
Adam

Reputation: 6132

Internet Explorer 11 executes ajax success condition but then freezes

Internet Explorer 11 seems to execute my ajax call successfully. It runs the code under the success condition all the way up to the last line in that block, updates the HTML DOM structure, but then freezes after that. The error I get in IE is: " is not responding due to a long-running script".

My code works in Chrome, Firefox and Safari!

Here's how I call function loadContentviaAjax when a user clicks a pagination link:

$(document).on('click', '.pagination-top a', function () {
    //CODE      
    loadContentviaAjax($(this).attr('href'), rawNewURL);
    console.log('20');
    return false;
});

Here's part of the codeblock in companysearch.js it concerns:

function loadContentviaAjax(furl, rawNewURL) {
    var webserviceURL = rawNewURL;
    $.ajax({
        type: "GET",
        url: webserviceURL,
        data: "",
        cache: false,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        error: function () {
            $("#loadstatus").html($("#whoops").attr('data-message')).addClass('box_error');
        },
        success: function (data) {
            console.log('0');

            //MORE OF MY CODE

            console.log('18'); //<-- this line is still logged
        } 
    });                 
return false
}

I tried: - commenting out all code in the success block of my AJAX call - tried settings breakpoints in IE Developer Tools

but I can't narrow it down to the line that causes this issue.

The line

console.log('20');

is also hit, so IE freezes after that, but apart from the loadContentviaAjax I can't narrow down what is causing the freeze....please help!

Upvotes: 1

Views: 2950

Answers (1)

Menno van den Heuvel
Menno van den Heuvel

Reputation: 1861

Alright! I found the piece of code that's causing the hang in IE11. I'm not quite sure how you're going to fix it, but I figured you would want to know.

Setting up the js debugger before clicking the link, and then pausing execution shows javascript to be spending all of its time in http://pagead2.googlesyndication.com/pagead/osd.js . So your code has little to do with it.

Stepping through indicates that Google's code is somehow stuck in an infinite loop jumping from function a to b to c to function a again. It spends most of the time in the catch block for a call to getBoundingClientRect on an iframe that has no parent (throws Unspecified Error).

When I keep http://pagead2.googlesyndication.com/pagead/osd.js from downloading using Fiddler, your navigation works fine.

I wish I could just tell you to "change this or that and it will work", but I can't find it - minified Google code is hard to debug. Is it possible your code is leaving the google ads container orphaned somehow?

Upvotes: 2

Related Questions