我试图实现下面的代码,它运行成功,但是通过成功函数正确地吹。我在那里只显示一个提示,但是下面的jquery消息调用没有出现。 (消息功能在其他情况下在同一页面上工作)。jquery Ajax post成功/错误函数
使用jquery 1.6。
任何想法为什么代码没有执行,因为它应该?谢谢!
$(document).ready(function(){
$('#postride').submit(function() {
dataString = $("#postride").serialize();
$.ajax({
type: "post",
url: "postride.php",
data:dataString,
error: function() {
alert('error!');
$(".message").text('An error occurred');
$(".message").fadeIn("slow");
$(".message").delay(2000).fadeOut(1000);
},
success: function() {
alert('success!');
$(".message").text('Your post has been completed');
$(".message").fadeIn("slow");
$(".message").delay(2000).fadeOut(1000);
setTimeout(function() { top.location.href="view.php" }, 3000);
}
})
});
});
完美的工作。谢谢!! – Matt