jQuery AJAX 使用 fadeIn +替换为
有几个问题& a's on this,但我发现没有一个能解决我的问题。我对此感到困惑。如果您知道对此问题的可用答案,请将我重定向到链接。
我的页面有一个空的 DIV #posts_insert
,其中通过 Ajax 插入新帖子。
$.ajax({
url: 'chat/posts_submit/' + <?php echo $page_id; ?>,
type: 'POST',
data: $('#posts_form').serialize(),
dataType: 'html',
success: function(html) {
$('#posts_insert').replaceWith(html);
}
});
我希望新帖子淡出,替换 #posts_insert
。在fadeIn
之前,我已经使用hide()
尝试了几次成功
迭代,但我就是无法完成这项工作。
有什么想法如何解决这个问题吗?提前致谢。
There are several q & a's on SO on this but I found none that address my issue. And I'm stumped with this. Please redirect me to a link if you know of an available answer to this.
My page has an empty DIV #posts_insert
in which new posts are inserted via Ajax.
$.ajax({
url: 'chat/posts_submit/' + <?php echo $page_id; ?>,
type: 'POST',
data: $('#posts_form').serialize(),
dataType: 'html',
success: function(html) {
$('#posts_insert').replaceWith(html);
}
});
I want that new post to fade in, replacing #posts_insert
. I've tried several iterations on success
using hide()
prior to fadeIn
but I just can't make this work.
Any ideas how to solve this? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
怎么样:
这是一个工作示例: http://jsfiddle.net/andrewwhitaker/jTLn5/
How about:
Here's a working example: http://jsfiddle.net/andrewwhitaker/jTLn5/
像这样的东西吗?
Something like this?
你可以尝试:
可能会给你你正在寻找的效果。
编辑:
为什么不在 (#posts_insert) 周围放置一个容器,将其淡出,replaceWith(),然后淡入容器呢?
you could try:
might give you the effect you're looking for.
EDIT:
Why don't you put a container around the (#posts_insert), fade that out, replaceWith(), and fadeIn the container?