[jQuery] Two .ajax POSTS not working?
Hi all,
I have the following code run when a button is clicked:
// Check the username isn't taken
var dataString = 'username='+ username + '&password=' + password;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "bin/login-check.php",
data: dataString,
success: function(msg) {
if(msg=='yes') {
errors = 1;
$("div#username-error").addClass("red");s
$("div#username-error").show();
$("div#username-error").html('Your username and/or password are
incorrect.');
$("input#username").focus();
var username_error = 1;
return false;
} else {
// If there are no errors, post the form
if(errors != 1) {
var dataString2 = 'username='+ username + '&password=' + password;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "bin/login-process.php",
data: dataString2,
success: function(msg) { $('#page').html(msg); }
});
return false;
}
}
});
But for some reason it isn't running correctly.. If I remove this
piece of code, the rest of the button works so I guess it's to do with
this bit, but I have NO idea why!
Thank you,
Rometh