مسج تحميل محتوى div (المقدمة ديناميكيا)
سؤال
لدي حمس يتم إنشاؤه HTML عبر محرك التعبير. أنا أستخدم 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!
}
});
أنا فقط أريد أن #panel div لإعادة تحميل / التحديث.
المحلول
أفترض أنك تبحث عن شيء من هذا القبيل:
$('#login-form').ajaxForm({
success: function( data) {
$("#panel").html( data);//Will insert new content inside div element.
}
});
يصلح:
$('#login-form').ajaxForm({
target: '#panel', //Will update the "#panel"
success: function( data) {
alert( "Success");
}
});
نصائح أخرى
إلى حد كبير أيا من الأساليب المدرجة في قسم "التلاعب" في Jquery's ستفعل ما تريد: http://docs.jquery.com/manipulation.
ولل تتلاشى الجميل في
success : function(data) {
$("#panel").hide().html(data).fadeIn('fast');
}
لا تنتمي إلى StackOverflow