jQuery Loading Example

jQuery Loading Example:

index.html:

[html]
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>jQuery Loading Index</title>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">

</script>
<script type="text/javascript">
function openWelcomePage() {
$(‘#jd’).html(‘<img src="loading.gif"/>’);
var loadingTime = setTimeout("$(‘#jd’).load(‘welcome.html’);", 2000);
}
</script>

</head>

<body>
<div id="jd">
<input type="button" value="welcome" onclick="openWelcomePage()" />
</div>
</body>
</html>
[/html]

 Welcome.html

[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>welcome</title>
</head>
<body>Welcome to Javadomain.in
</body>
</html>
[/html]

Note: Ensure you have the loading image in the same path of html files.

Output:

welcome button

loading jquery

welcome page content after loading

 

 

 

Recommended Books:

Leave a Reply