jQuery $.post()函数不能在IE中工作,除非开发者工具打开


jQuery $.post() function not working in IE unless developer tools is open

jQuery $.post()函数在IE中不工作。我试着打开开发人员工具,看看我是否得到一个控制台错误,但奇迹般地这个功能开始工作了。

它只是一个标准的$.post()函数

$.post('child_cb.php?type=check', { value: $(this).val() }, function(data) {
                        console.log(data);
                        if (data == 'true') {
                            $(".check_case").removeClass('bad').addClass('good');
                        }
                        else if (data == 'false') {
                            $(".check_case").removeClass('good').addClass('bad');
                        }
                    });

我看不出有什么理由不行。

删除/注释出console.log(data), IE不能处理这个,它应该工作正常后,你删除它。

您应该养成在调试时使用它的习惯,这样您就不会忘记console.log:

if(!('console' in window) || ( ('console' in window) && !('log' in console) )){  
    window.console = {  
        log:function(e){  
            alert("You are using console log without the console!")  
        }  
    }  
}

您可以删除警报,但如果您想要通知您忘记了某些内容,则可以。:)