Im getting an error 200 in my ajax request. Im wanting to post 1 value which is a email address to the page in my ajax request. Could someone tell me what is wrong
Error:
message=:[object Object], text status=:parsererror, error thrown:=SyntaxError: JSON.parse: unexpected end of data
just changed to $.parseJSON it works with no error but the success function doiesn’t alert
JQuery
$('#checkemail').click(function() {
var json = $.parseJSON({ "email": $('#email').val() });
$.ajax({
url:'http://' + location.host + '/buyme/include/getemailaddress.php',
type:'POST',
contentType: "application/json; charset=utf-8",
data: json,
dataType:"json",
success: function(msg) {
alert(msg);
},
error: function(msg, textStatus, errorThrown) {
alert( 'message=:' + msg + ', text status=:' + textStatus + ', error thrown:=' + errorThrown);
}});
});
yes the piece of code you have posted expects json to be recieved from
getemailaddress.phpin your php file try putting
and most probably things will work out for you
EDIT
for example from the php script you are sending an array like
in the success handler of your ajax request you can do something like