javascript错误或没有线索

javascript错误或没有线索,javascript,jquery,internet-explorer,Javascript,Jquery,Internet Explorer,我得到了以下javascript代码。 基本上,它可以在FF和IE上使用开发工具 $(function(){ console.log("it is ok"); var mybutton=""; alert("ready1"); $('button[name="delorder"]').click(function(){ console.log($(this).val()+"hay i got a click"); mybutto

我得到了以下javascript代码。 基本上,它可以在FF和IE上使用开发工具

$(function(){
    console.log("it is ok");
    var mybutton="";

    alert("ready1");
    $('button[name="delorder"]').click(function(){

        console.log($(this).val()+"hay i got a click");
        mybutton=$(this).val();
        alert("a click1");
        $.ajax({
            type:'POST',
            url:'deleteorderitem.php',
            data:mybutton,
            success:function(result){

                if((result.indexOf("t") < 3) && (result.indexOf("t") >= 0)){                    

                    $('#orderresult').html(result);                 

                    console.log("i am 3 ");
                    console.log("index of t is "+result.indexOf("t"));
                }else{
                    console.log("i am 4");                      
                    console.log("index of t is "+result.indexOf("t"));
                    $('#divOrderButton').hide();
                    $('#orderresult').html("");
                    $('#divNoinfo').html("There is no record to display at the moment.");
                    $('#divNoinfo').show(); 
                    $('#divOrder').hide();
                }
            }
        });
    });
});
</script>
$(函数(){
console.log(“一切正常”);
var mybutton=“”;
警惕(“准备就绪”);
$('button[name=“delorder”]”)。单击(函数(){
log($(this.val()+“我点击了一下”);
mybutton=$(this.val();
警报(“点击1”);
$.ajax({
类型:'POST',
url:'deleteorderitem.php',
数据:mybutton,
成功:功能(结果){
如果((result.indexOf(“t”)<3)和&(result.indexOf(“t”)>=0)){
$('#orderresult').html(结果);
控制台日志(“我是3”);
log(“t的索引为”+result.indexOf(“t”));
}否则{
console.log(“我4岁”);
log(“t的索引为”+result.indexOf(“t”));
$('#divOrderButton').hide();
$('#orderresult').html(“”);
$('#divNoinfo').html(“目前没有可显示的记录”);
$('#divNoinfo').show();
$('#divOrder').hide();
}
}
});
});
});
但是,它不适用于IE(没有开发工具)。 因此,任何建议都将不胜感激。
谢谢

这主要是因为

console.log()
当开发人员工具未打开时,Windows IE8及以下版本没有控制台对象

要么注释掉显示console的行。或者预先创建控制台对象

试试这个。。。不确定这是否正确

var alertFallback = true;
   if (typeof console === "undefined" || typeof console.log === "undefined") {
     console = {};
     if (alertFallback) {
         console.log = function(msg) {
              alert(msg);
         };
     } else {
         console.log = function() {};
     }
   }

如果控制台对象不存在,这将创建它。

如果你说没有开发工具打开它就不能工作(除非我弄错了),那是因为你有所有的
控制台.log
,这一定是导致它崩溃的原因

在主JS文件的最顶端尝试类似的方法,以防止IE中出现这种情况

if (typeof (console) === 'undefined' || !console) {
    window.console = {};
    window.console.log = function () { return; };
}

我使用此函数为跨浏览器控制台日志写入日志:

/**
 *Log into the console if defined 
 */
function log(msg)
{       
    if (typeof console != "undefined") {
        console.log(msg);
    }       
}

IE的输出是什么?你收到警报了吗?错误是什么?它是如何工作的呢;仅适用于开发者工具windowalert(“ready1”);不显示,当我再次单击按钮时发出警报(“单击1”);没有出现是的,苏珊斯是对的。我是在注释console.log时得到的。再次谢谢你。。的确,console.log让我头疼。谢谢你!我在JS中添加了这个规则,以防开发人员在其中留下日志,这样它就不会在生产中中断!