jquery ajax call firing both success and error
I have the following code to make an ajax request and both the success and error events are being called. This is occurring intermittently in Opera and Chrome but not IE8 (I dont have access to a higher version at the mo to check). The textStatus parameter shows error but the errorThrown parameter is emmpty. The responseHeader is null.
$.ajax({
type: "POST",
url: "ajax/check_login.php",
data: $(form).serialize() + "&session_key=<?php echo session_id(); ?>" + "&role=" + refer,
timeout: 3000,
success: function(resp) {
if (resp == 'error') {
$('#login_error').html('Invalid login');
} else {
if (refer == 'customer') {
self.location='book-mot.php';
} else {
self.location='admin.php';
}
}
},
error: function (request, textStatus, errorThrown) {
alert(request.getResponseHeader('Status'));
alert('text status: ' + textStatus + ' errorThrown: ' + errorThrown);
}
});
return false;
}
});
The code redirects the user to the appropriate place after a successful login but it first displays the alert box from the error function.
thanks a lot for any help you can give
链接地址: http://www.djcxy.com/p/6672.html上一篇: 在Asp.net MVC 4中,jQuery Ajax请求在移动设备上发生错误
下一篇: jquery ajax呼吁成功和失败