Good day stackoverflow‘ers
I’m doing a simple AJAX form, imagine some kind of registration.
This form posts the value to a PHP file which posts this to a database and returns a string like this one “success id:12345“. I want this script to read JSON and check ID, success and so, the current code is:
// Some pieces of code
success: function(data){
var reponse = $.trim(data);
if (reponse.toLowerCase().indexOf("yes") >= 0){
// check the id (Don't know how)
alert("Your id is "+id);
}else{
alert(reponse);
}
}
Thanks!
PHP:
Then
json_encode($response);The browser will get this…
You can make the ajax request and jQuery will parse the JSON for you.