jQuery reload div's content (dynamically rendered)

こ雲淡風輕ζ 提交于 2019-12-17 20:25:56

问题


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

$('#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.


回答1:


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");
    } 
});



回答2:


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




回答3:


And for your pretty fade in

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


来源:https://stackoverflow.com/questions/932777/jquery-reload-divs-content-dynamically-rendered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!