javascript - checking returned data from PHP script through jquery -
i have written php script
cch.php
$stmtcheck = $mysqli->prepare("select id members email=? , unlock_code=?"); $stmtcheck->bind_param("si", $_session['unlockemail'], $_post['code']); $stmtcheck->execute(); $stmtcheck->bind_result($id); $stmtcheck->fetch(); $stmtcheck->close();
and jquery submitting form is
recover.php
$("#formunlock").submit(function(e) { e.preventdefault(); $.ajax( { url: '../scripts/cch.php', method: 'post', data: $(#formunlock).serialize(), success: function() { alert("unlocked"); } }); });
now want check whether $id
has value or not! how fetch $id
variable main script?
in cch.php, if want pass id javascript, can print id
echo $id;
what ever data received on ajax response passed parameter success callback function. either have execute success actions inside succes call or have write function executed on ajax success , call function , pass params
$("#formunlock").submit(function(e) { e.preventdefault(); $.ajax( { url: '../scripts/cch.php', method: 'post', data: $(#formunlock).serialize(), success: function(responsedata) { if (responsedata == '' ) { alert("sorry failed"); } else { alert("success"); } } }); });
Comments
Post a Comment