显示spinner.gif在Ajax调用在Grails的加载时间 [英] Showing spinner.gif in ajax call on loading time in grails

查看:174
本文介绍了显示spinner.gif在Ajax调用在Grails的加载时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜  我正在开发中的Grails Web应用程序,它使用大量ajax.I的需要出示spinner.gif图像在处理AJAX request.My样品GSP code为

Hi I am developing a web application in grails which uses lot of ajax.I need to show a spinner.gif image while processing the ajax request.My sample gsp code is

<div id="ajax-area">
  <g:remoteLink action="list" controller="file" update="ajax-area">
    view files
  </g:remoteLink>
</div>

在上面的code如果我们点击查看文件链接,它会更新Ajax的区域股利。

In the above code if we click on the view files link it will update the ajax-area div.

能否有人告诉我如何与spinner.gif上加载AJAX更新Ajax的区域。

Could some one show me how to update the ajax-area with spinner.gif on loading ajax.

感谢

推荐答案

假设你使用的原型,你可以添加一些像这样的页面(或布局)来显示一个微调:

Assuming that you use Prototype, you can add something like this to the page (or the layout) to show a spinner:

<script type="text/javascript">
Ajax.Responders.register({
   onCreate: function() {
      if($('ajax-area'))
         $('ajax-area').update('<img src="${createLinkTo(dir:'images',file:'spinner.gif')}" border="0" alt="Loading..." title="Loading..." width="16" height="16" />');
   }
});
</script>

它覆盖AJAX区域元素将在启动Ajax调用的内容。

It overwrites the content of the 'ajax-area' element when the Ajax call is initiated.

这篇关于显示spinner.gif在Ajax调用在Grails的加载时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆