Here's my JavaScript Code:
$.post("Actions.php", {
'recaptcha': grecaptcha.getResponse(),
'email': $("#emailInput").val(),
'Password': $("#passwordConfirm").val(),
},
function(data) {
console.log(data);
})
Now the post request was successfully executed, but console.log(data)was ignored by JQuery.
I tried to search for any possible errors from the documents,but nothing found.
Anything wrong with my code?
Thanks.
When providing a success, JQuery probably parses your POST data/body object as its settings object instead
It should work if you move the callback to a .done
edit: mis-read the jQuery.post documentation, ignore the above
Try adding a handler for both done and fail:
$.post("Actions.php", {
'recaptcha': grecaptcha.getResponse(),
'email': $("#emailInput").val(),
'Password': $("#passwordConfirm").val(),
})
.done(function(data, textStatus, jqXHR) {
console.log("Success ", data);
})
.fail(function(data, textStatus, jqXHR) {
console.log("Failed ", textStatus);
});
.done is run on a 'successful' response, .fail for failure responses, and .always for any response