You misunderstood the documentation. The described "response" is what you'll have coming back from your server-side code. You do not "return
" anything within remote
.
MailingListID: {
remote: {
url: 'checkMailingListID.php',
type: 'POST',
}
}
Since your server-side script is PHP, then simply echo
a true
, false
or a JSON formatted string representing your error message.
http://jqueryvalidation.org/remote-method/
"The serverside resource is called via jQuery.ajax (XMLHttpRequest) and gets a key/value pair corresponding to the name of the validated element and its value as a GET parameter. The response is evaluated as JSON and must be
true
for valid elements, and can be anyfalse
,undefined
ornull
for invalid elements, using the default message; or a string, eg. "That name is already taken, try peter123 instead" to display as the error message."
Side note: This is exactly the default behavior... so you don't need the submitHandler
option at all...
submitHandler: function(form) {
form.submit();
}