我试图使用before()显示ajax请求的结果。它工作得很好,但现在我想用动画(切换,滑动或其他)显示结果。jquery之前()动画
这里是我使用的代码:
jQuery.ajax({
type: "POST",
url: "/postcom",
dataType:"text",
data:myData,
success:function(response){
$("#results_com").before(response);
$("#formcomtext").val('');
},
error:function (xhr, ajaxOptions, thrownError){
console.log(thrownError);
}
});
HTML:
<div id="results_com></div>
感谢
不工作...它仍然会出现在一个镜头...... – Recif
插入后试试'.hide()'。我只是给你一个让链条继续前进的方式,而不必穿越新的dom。或者,使用CSS来隐藏任何“结果”,并使用jquery为其设置动画。 – kalley
我尝试了$(response).insertBefore(“#results_com”)。hide()。animate({},400);但现在它不再工作了(没有什么是由AJAX插入的) – Recif