I have a php script which returns either a success or error. the success actually returns an empty array, but it allows the success calls in javascript to occur.
I know that i can use a header to do errors, such that the error will fire, but how do i return it custom strings?
example of success:
header("Content-Type: application/json");
echo json_encode(array());
Example of error i was trying.:
header("Wrong Pasword.", true, 400);
echo "Wrong Password.";
Neither the first arg of header nor the echo is returned to the client side. I am trying to return a custom error so that way i can, in javascript say:
$.ajax({
url:"script.php",
success:function(){},
error: function(error){
alert(error);
}});
in this sample, i was trying to have error be: "Wrong Password."