jQuery ajax fails in IE

I have this supper weird bug, where this method fails in IE9. What is supper weird is that if the IE [Developer Tools] are open, the method does not fail. I have no idea how just by being open the window changes the execution of the script.

When I exec this script with IE [Developer Tools] open, the function executes as expected. When the IE [Developer Tools] is closed, it executes:

   alert("00000000000000000000000000000000000");
   alert("4444444444444444444");

And that's it, no other alerts are fired.

I have tried removing the timeout: 20000 and cache: false, but it did not help.

  function postAssets(datapm) {
        alert("00000000000000000000000000000000000");

        $.ajax({
            type: "POST",
            url: "Igud.aspx/PostD",
            cache: false,
            contentType: "application/json; charset=utf-8",
            data: '{"postedData":"' + datapm + '"}',
            dataType: "json",
            timeout: 20000,
            tryCount: 0,
            retryLimit: 10,
            success: function (msg) {
                alert("4444444444444444444");
                console.log('success postAssets ' + msg.d);
            },
            complete: function (jqXHR, status) {
                alert("44444444444aaaaaaaaaaaaaaaaaaaaaaaaaaaa44444444");
                if (status == 'success' || status == 'notmodified') {
                    alert("aaaaaa");
                    console.log('complete postAssets' + jqXHR.responseText);

                    var obj = jQuery.parseJSON(jqXHR.responseText);

                    alert("bbbb");
                    //  alert(parseInt(obj.d));
                    //   alert(parseInt(obj.d) == 1);
                    if (parseInt(obj.d) == 1) {
                        $("#thxbox").html("TEST");
                        alert("ccc");

                        if ($("#Q3_3").attr('checked') == 'checked') {
                            $("#thxboxMd").dialog("option", { height: 470 }); alert("dddd");
                            $("#thxboxReg").show(); alert("eeee");
                            $("#thxbox").effect("pulsate", { times: 3 }, 1200); alert("ffff");
                        }
                        else {
                            $("#thxboxReg").hide();
                            $("#thxboxMd").dialog("option", { height: 180 });
                        }

                        $("#thxboxMd").dialog("open");
                        $("body").off("click", "#sbbtn");

                        $('body').on('click', '#sbbtn', function () {
                            $("#thxbox").html("TEST");

                            if ($("#Q3_3").attr('checked') == 'checked') {
                                $("#thxboxMd").dialog("option", { height: 470 });
                                $("#thxboxReg").show();
                                $("#thxbox").effect("pulsate", { times: 3 }, 1200);
                            }
                            else {
                                $("#thxboxReg").hide();
                                $("#thxboxMd").dialog("option", { height: 180 });
                            }

                            $("#thxboxMd").dialog("open");
                        });

                    }
                    else {
                        $("#thxbox").html("TEST");
                        $("#thxboxMd").dialog("open");
                        $("#thxbox").effect("pulsate", { times: 3 }, 900);
                    }
                }
            },
            error: function (req, status, error) {
                alert("444444444444411111111111111111112222222222222222444444");
                this.tryCount++;
                if (this.tryCount <= this.retryLimit) {
                    var offSet = this.tryCount * 1000;
                    getAssetsRecovery = this;
                    var retry = function () { $.ajax(getAssetsRecovery); };
                    setTimeout(retry, offSet);
                    console.log(arguments);
                    console.log('error postAssets' + error);

                    $("#thxbox").html("TEST");
                    $("#thxboxMd").dialog("open");
                    $("#thxbox").effect("pulsate", { times: 3 }, 900);

                    return;
                }
                console.log('error postAssets');
            }
        });

}

Answers


Does this answer your question? It seems the console object is not available when the debugger has not been opened.

Does IE9 support console.log, and is it a real function?


Your first alert is

alert("00000000000000000000000000000000000");

when the function is success it alerts alert("4444444444444444444");

and it wont enter the error and complete function the alert will only happen on those corresponding events(if its error or something else..)

Try changing the url: "Igud.aspx/PostD", to something else..you will get the alert in error section '


Need Your Help

How to enable Eclipse to autobuild/autosave changes before run (CDT)

c++ eclipse eclipse-cdt autosave auto-build

I'm trying to conveniently have the updated code in effect when I click the run button in Eclipse. At present it will run the last build and I have to manually click build before clicking run to s...

my php if statement doesn't work

php if-statement header

This is my first time asking a question in this website so please bear with me. I got a script from another website for testing internet connection speed and added if else statement. If the speed i...