weixin_33724046 2014-04-10 22:17 采纳率: 0%
浏览 61

在ajax加载时添加div

I put this code:

<script type='text/javascript' src='http://code.jquery.com/jquery-2.1.0.min.js'></script>
<script type="text/javascript">
 $(document).ajaxStart(function() {
  $("#loading-image").show();
});

$(document).ajaxStop(function() {
  $("#loading-image").hide();
});

on the top of the page...

and I have HTML:

<body style="">
<div id="loading-image" style="width:100%; height:100%; background:#ccc; display:none;"></div>

But I dont see ID loading image on ajax... What can be a problem here?

  • 写回答

2条回答 默认 最新

  • weixin_33709219 2014-04-10 22:23
    关注

    From the limited amount that you posted, it doesn't look like you're actually making an AJAX request. http://jsfiddle.net/volte/A66C8/

    Try then making an ajax call when the page loads:

    $.ajax({
      url: "test.html",
      context: document.body
    });
    

    Disclaimer: I have not tested this. Pulled from http://api.jquery.com/jQuery.ajax/

    In addition, make sure you wrap those methods in an onload. Most people do:

    (function() {
      //... your code here ...
      //... will be run on load...
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据