Chrome shows additional chars at the beginning and ending of the response because of that I cant use if statements such as
if(result=="Saved"){
alert("Yihuu");
}
With firefox I dont have any problems.
How can I prevent this issue?
JavaScript Code
$.ajax({
url: "http://localhost:8080/RestHmdy/api.php/register",
type: "POST",
data: JSON.stringify(user),
contentType: 'application/json; charset=utf-8',
success: function (result) {
alert(result);
},
error: function (xhr, status, err) {
alert("Error "+err,xhr,status);
}
})
PHP Response Code
if($stmt->execute()){
echo "Saved";
}else{
echo "Unsaved";
}