Lets say you want to check if your query successfuly executed.
The javascript JQuery whould be like this :
$.ajax({
type: "POST",
url: "./update.php",
data : {
'id' : $("#id").val() },
success: function(data)
{
var obj = jQuery.parseJSON(data);
alert(obj[0].result);
}
});
And the PHP script of update.php like this :
include "./includes/database.php";
if (mysql_query("select id from table where id = '".$_POST['id']."'"))
{
$return[] = array('result' => 'id exists');
}
else
{
$return[] = array('result' => 'id not found');
}
echo json_encode($return);
No comments:
Post a Comment