Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jqueryajax没有';我不在IE工作_Ajax_Jquery - Fatal编程技术网

jqueryajax没有';我不在IE工作

jqueryajax没有';我不在IE工作,ajax,jquery,Ajax,Jquery,我有以下功能在我的购物篮中添加一篇文章: $(".addtocart").click(function(){ var product = $("#pid").val(); var qty = $("#qty").val(); if(isNaN(qty) || qty == '') alert("ERROR"); else{ alert("HIHI"); $.ajax

我有以下功能在我的购物篮中添加一篇文章:

$(".addtocart").click(function(){

   var product = $("#pid").val();
   var qty = $("#qty").val();
   if(isNaN(qty) || qty == '') alert("ERROR");
   else{                                    
        alert("HIHI");

        $.ajax({
            type:"post",
            url:"index.php",
            data:"page=ajax&action=add_product&product=" + product + "&qty=" + qty,
            success: function(html){
                alert("AAA");
                /*
                $("#maininf").html($("#thumbimg").html());
                $("#tinfo").html(html);
                var leftPoint = (Fensterweite()-$(".readybuy").width())/2;
                $(".readybuy").css("left",leftPoint);
                $(".glassbox").fadeIn();
                $(".readybuy").fadeIn();
                */
            },
        });
   }
第一个警报在IE中每次都会发出。 beforeSend步骤也在工作。 但第二次警报永远不会到来。 有人知道为什么它在IE上不起作用吗

谢谢。

$(“.readybuy”).fadeIn();
            $(".readybuy").fadeIn();
            */
        },  < - Extra comma will break IE
    });
}
*/ },<-额外的逗号将打断IE }); }
首先需要删除尾随逗号:

   $.ajax({
           ...
        } // No comma here
    });

是一个很好的工具来确保你的Javascript是好的。解析器错误很常见,我也经常遇到这样的情况:Firefox工作正常,但Safari由于缺少/额外的逗号而吐在同一个脚本上。

您可能还想在ajax调用中添加一个错误部分,以防它出错,否则您不会知道

$.ajax({
    type:"post",
    url:"index.php",
    data:"page=ajax&action=add_product&product=" + product + "&qty=" + qty,
    success: function(html){
        alert("AAA");
        /*
        $("#maininf").html($("#thumbimg").html());
        $("#tinfo").html(html);
        var leftPoint = (Fensterweite()-$(".readybuy").width())/2;
        $(".readybuy").css("left",leftPoint);
        $(".glassbox").fadeIn();
        $(".readybuy").fadeIn();
        */
    },
    error: function(error) {
        alert(error);
    }
});

非常感谢,但这是另一个错误。
请求的php页面需要以下行:

header("Content-Type: text/html; charset=utf-8");
现在一切都很好