jQuery 重新加载 div 的内容(动态渲染)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/932777/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 10:10:07  来源:igfitidea点击:

jQuery reload div's content (dynamically rendered)

jquerypluginsrefreshreload

提问by Kevin Brown

I have a div that is generated html via Expression Engine. I'm using ajax submit:

我有一个通过表达式引擎生成 html 的 div。我正在使用ajax提交:

$('#login-form').ajaxForm({  
    // success identifies the function to invoke when the server response 
    // has been received; here we apply a fade-in effect to the new content 
    success: function() { 
    $("#panel").RELOAD!!();//Just refresh this div!
    } 
}); 

I just want the #panel div to reload/refresh.

我只希望#panel div 重新加载/刷新。

采纳答案by Artem Barger

I assume you looking for something like that:

我假设您正在寻找类似的东西:

$('#login-form').ajaxForm({  
    success: function( data) { 
    $("#panel").html( data);//Will insert new content inside div element.
    } 
});

FIX:

使固定:

$('#login-form').ajaxForm({ 
    target: '#panel', //Will update the "#panel"
    success: function( data) { 
    alert( "Success");
    } 
});

回答by Gabriel Hurley

Pretty much any of the methods listed in jQuery's "manipulation" section are going to do what you want: http://docs.jquery.com/Manipulation

jQuery 的“操作”部分中列出的几乎所有方法都可以执行您想要的操作:http: //docs.jquery.com/Manipulation

回答by Paul Tarjan

And for your pretty fade in

为了你漂亮的淡入

success : function(data) {
   $("#panel").hide().html(data).fadeIn('fast');
}