0

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

}

JohnFx
  • 33,720
  • 18
  • 99
  • 158
Registered User
  • 3,535
  • 10
  • 39
  • 63

2 Answers2

3

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?

Community
  • 1
  • 1
pilotcam
  • 1,719
  • 14
  • 22
  • 1
    Great point. I don't like using console.log(). It makes sense to me to make a custom function that allows you to safely attempt to log messages to the console, and always call that. The function should attempt, but silently fail if console.log or whatever is not available/possible. – Ian Jun 19 '12 at 03:28
  • Damn, this one almost got me killed. I will never use console again. This was a punishment for betraying the Alert() box, I was using for the past decade. – Registered User Jun 19 '12 at 11:17
0

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 '

coolguy
  • 7,608
  • 9
  • 41
  • 70