views:

575

answers:

6

Hello, i have the following function to add an article in my basket:

$(".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();
                */
            },
        });
   }

the first alert is alling everytime in IE. the beforeSend Step is working too. But the second alert is never coming. Has anybody an idea why it doesn't work on IE?

Thanks.

+8  A: 
            $(".readybuy").fadeIn();
            */
        },  < - Extra comma will break IE
    });
}
Daren Schwenke
+1  A: 

You need to remove your trailing comma for a start:

   $.ajax({
           ...
        } // No comma here
    });
Greg
+1  A: 

http://jslint.com/ is a great tool to make sure your Javascript is good. Parser errors are common, I have often also had a case where Firefox works fine but Safari pukes on the same script because of missing/extra commas.

Jaanus
A: 

you also may want to add an error part to your ajax call just in case it errors out because otherwise you wont know

$.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);
    }
});
jmein
A: 

omg i love this page. :) Thank you very much but it was another error. The requested php Page needs the following line:

header("Content-Type: text/html; charset=utf-8");

And now everything works fine. :)

Thank you for help.

Congratualtions to the stackoverflow team.

Isn't it cool? Hours searching elsewhere = 5 min here. :)
Daren Schwenke
A: 

Yeah, it worked for me too after i corrected the header

Marcos Riso