当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Display loading gif when I load a JSP page

问题描述:

Lets say I have a JSP. When I call my JSP, it'll hit the database and displays the appropriate result. Coming to the point, since my JSP loads huge a value, it takes some time to load my page. So I need a loading gif while my page loads and that gif should disappear when my JSP fully loads. Can anyone help me by giving a sample code for this?

For example my code looks like this:

 <html>

<head>

</head>

<body>

Hello

</body>

</html>

So can anyone help me where to insert the loading gif code.

网友答案:

You need two JSPs for this. The first one returns the "please wait" GIF plus some JavaScript that invokes the second JSP, possibly by AJAX.

When the second JSP returns HTML, the JavaScript can then add that to the existing page.

You will want to use a JavaScript framework like jQuery for this. The documentation contains many examples how to send AJAX requests to a web server and process the results.

分享给朋友:
您可能感兴趣的文章:
随机阅读: