Search This Blog

2017/06/16

IE: js only working in debug mode

I happened to an issue that js function is working in Chrome, Firefox and IE's debug mode. ONLY IN DEBUG MODE.

In stackoverflow, most answer are "Don't use 'console.log'". Because console object exists in scope only in debug mode after IE9.
Or use codes likes below to avoid console's problem.
if(!('console' in window)){
    window.console ={};
    window.console.log=function(string){
        return string;
    };
}

But it's not working on my issue, and try to catch the error is non-help at all.
window.onerror = function(msg, url, line) {
    alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+line);
    return true;
}

Maybe it is cached that set to true somewhere, so I tried to set it to false.
$.ajax({
    type: "GET",
    url: "/" + filename,
    dataType: "xml",
    cache: false,
    success: function(xml){ /* code */ }
});

Success. Issue closed.

No comments :

Post a Comment