I'm new to Ajax and Jquery and want to perform some validation on a login page (using wordpress).
I use this code to catch the submit of the login form...
$("#login").submit(function (e) {
$.ajax({
type: "post",
dataType: 'json',
url: ajax_login_object.ThemeFolder + "/log-in-script.php",
data: {
'user_login': user_login,
'user_pass': user_pass,
'action': 'login'
},
success: function (data) {
if (data.succeeded == true) {
// JUST WANT TO SUBMIT THE FORM HERE
// tried return true.. no joy
// tried $("#login").submit() but just ends up with neverending loop
// tried document.href etc but lose the POST data
// tried nesting another ajax call but no joy
// ????
}
}
});
e.preventDefault();
});
In my log-in-script.php I check a few things. For instance, if they haven't filled in the Password field but their Username is in the database I reset their password. If they haven't filled in the Password field and their Username is not in the db then I register them.
If they have entered a Username AND a Password I just want to submit the form normally but I'm struggling on how to do this. I'm sure I'm missing something really simple.
Any help is really appreciated.
Thanks
John ;-)