There is a typo in your code:

data:"act=buy,

Closing quote is missing.

On Jul 11, 10:39 pm, raoh <hiy...@gmail.com> wrote:
> this is my code, a normal code as the examples on jquery.com
> ajax.php can only echo "OK1", "OK2" or "KO", so I wonder why none of
> the if in the success function work ? but the alert before works well
> and i set dataType = text just to be sure. It's like mess is another
> type of variable or what ? Thank you
>
> $.ajax({
>         type:"POST",
>         url:"ajax.php",
>         data:"act=buy,
>         cache:false,
>         dataType: "text",
>         beforeSend: function(){
>             // Loading
>         },
>         success: function(mess){
>             var txt = mess;
>                         alert(txt);
>             if(txt=="OK1")
>                 alert(txt);
>             if(txt=="OK2")
>                 alert(txt);
>             if(txt=="KO")
>                 alert(txt);
>
>         },
>         error: function(){
>             // Errore
>         }
>     });

Reply via email to