将事件处理函数放入$(document).ready(function(){…})中。它现在应该工作
还添加preventDefault()以限制页面刷新
$(document).ready(function() { $("#postcontent").submit(function(e) { e.preventDefault(); $.ajax({ type : "POST", url : "add_new_post.php", data: $("#postcontent").serialize(), beforeSend : function() { $(".post_submitting").show().html("<center><img src='images/loading.gif'/></center>"); }, success : function(response) { alert(response); $("#return_update_msg").html(response); $(".post_submitting").fadeOut(1000); } }); e.preventDefault(); }); });


