2012-11-19 24 views
0

我在我的Java EE应用程序下面的代码(JSP文件,从Servlet.java叫):异步格

<div class="drop">    
      <c:forEach var="widget" items="${widgets}"> 
       <div class="drag"> 
       <p><h2>Widget</h2></p> 
       // WIDGET GRAPHIC REPRESENTATION 
       </div> 
      </c:forEach> 
    </div> 
    <input class="add" type="image" src="image.jpg"> 

我要的是加载和显示在浏览器中的JSP文件,之后,加载小部件。只要未加载小部件,理想的情况就会显示加载图标。我怎样才能实现这样的异步解决方案?有人可以解释和/或给一个小演示吗?

+1

我认为jQuery的'load'事件将有助于 – Abubakkar

+0

可不可以给你的意思的例子吗? –

+0

它看起来像你几天前问过类似的东西:http://stackoverflow.com/a/13235938/980472你尝试了什么建议给你? – jddsantaella

回答

1

我想这应该帮助你,我不知道

//use id of div(that contains the widgets) that 
//you want to hide before all widget are shown 
$('#my_div_id') 
    .hide() // hide it initially and then use load event handler 
    .load(function() { 
     $(this).show();//display/show the div when load completes 
    }) 
; 
+0

感谢你的例子!如果我使用我的示例中的'drag'div,这是否意味着小部件的代码(此时为'WIDGET GRAPHIC REPRESENTATION')将放在'$(this).show()'这一行的正上方? –

+0

可以试试这个例子。这是一个jquery代码,你只需要保留你的代码,你已经在你的问题中发布了代码,并且在你的head标签中写了两个脚本标签,一个在jsp中导入jquery,另一个代码包含我拥有的代码在我的回答中提到。只需寻找一个基本的jQuery教程。 – Abubakkar

+0

非常感谢你或你的帮助:) –