我的问题很简单。我起草了如下代码,用于在发布表单时显示加载图像。加载图像可以正常显示。但返回结果后不能自动隐藏。我可以知道错误是什么吗?
HTML
<div id="loading"></div>
Ajax
function email_subscribe(){
$('#loading').html('<img src="loading.gif"> loading...');
$.ajax({
type: 'post',
url: 'index.php?subscribe',
dataType: 'html',
data:$("#subscribe").serialize(),
success: function (html) {
$('#loading').html();
eval(html);
}});
}
最佳答案
您只是调用 .html()
方法,不带任何参数(充当 getter)。要实现您在此处寻找的内容,您至少需要像空字符串一样传入 set
并覆盖现有内容。
$('#loading').html('');
关于javascript - Ajax加载图片错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28433786/