Jquery post and get data from PHP

Posted by Sergio on Stack Overflow See other posts from Stack Overflow or by Sergio
Published on 2010-05-29T16:39:19Z Indexed on 2010/05/29 16:42 UTC
Read the original article Hit count: 303

Filed under:
|

Jquery code looks like:

$('#gal').rating('gl.php?gal_no=<?=$gal_no;?>&id=<?=$id;?>', {maxvalue:10,increment:.5, curvalue: <?=$cur;?>});

PHP code:

$br=mysql_query("SELECT count(gal) as total FROM ...")
if ... {
echo '0';
}
else echo '1';
}

Jquery code successfully transmitted data to PHP script and when the PHP done with checking data echo the result ('1' or '0'). How can I get this PHP result back to Jquery and based on them write a message? Some thing like:

if(data=="1")
{
$("#error").show("fast").html('not correct').css({'background-color' : '#F5F5F5','border-color' : '#F69'});
}else{
$("#error").show("fast").html('correct').css({'background-color' : '#FFF','border-color' : '#3b5998'}); 
}

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery