显示外部页面并在div中加载gif
|
我可以使div显示外部页面的内容,但不会显示加载的gif。任何人都可以更正我的代码。 TIA
<a href=\"javascript:void(0);\" id=\"load-extmsg\">blah</a>
<script type=\"text/javascript\">
$(document).ready(function(){
$(\'#load-extmsg\').click(function(){
$(\"#extmsg\").load(\"blah.php\", function(){
$(\"#ajaxLoader1\").remove();
});
});
</script>
<div id=\'extmsg\'><img src=\"/images/ajaxLoader2.gif\" id=\"ajaxLoader1\"/></div>
经过一番尝试和错误之后,下面是正确的代码:
<a href=\"javascript:void(0);\" id=\"load-extmsg\">blah</a>
<script type=\"text/javascript\">
$(document).ready(function(){
$(\'#load-extmsg\').click(function(){
$(\"#ajaxLoader1\").show();
$.post(\'blah.php\', function(data){
$(\"#ajaxLoader1\").remove();;
$(\"#extmsg\").append(data);
})
});
});
</script>
<div id=\'extmsg\'><img src=\"/images/ajax-loader2.gif\" id=\"ajaxLoader1\" style=\"display:none;\" /></div>
没有找到相关结果
已邀请:
2 个回复
磨标烫徽啪
添加一些CSS以隐藏加载图像:
赣借