javascript - Issue using remote method in jquery validation -
i'm following this article in order validate form
my problem when have use remote
method, e.g. remote: "check-username.php"
since documentation remote method not clear me, know:
how need structure json output in php script?
you don't need json. can put text. example can
echo "success";
for passed validation, , enter validation message like:
echo "username exists.";
for failed validation.
in callback this:
remote: { url: "check-username.php" , type: "post" , data: { username: function() { return $("#username").val(); }, complete: function(data){ if( data.responsetext != "success" ) { alert(data.responsetext); //handle failed validation } } }