I have a simple registration page that validates if a user is already taken.
I use ajaxSetup for all my ajax calls and for some reason the "success" is never called. When I look at my console (firebug) I can see a successfully request (code 200 OK and I get true or false as the result).
Here's my code:
$('#checkValidUsername').click(function() {
// some basic validation like not empty etc...
$.ajax({
type: "POST",
url: '/checkuser.php',
cache: false,
data: $("#form").serialize(),
dataType: 'json',
success: function(result) {
// do some actions
},
});
}
$.ajaxSetup({
beforeSend: function() {
// show loading dialog // works
},
complete: function(xhr, stat) {
// hide dialog // works
}
success: function(result,status,xhr) {
// not showing the alert
alert('success');
}
});
What is wrong with my code? Thank you