Category: jquery

jquery loading page

สำหรับท่านใดต้องการเขียนเว็บให้มีลักษณะ page loading สามารถใช้ jquery ดังนี้

<!doctype html>
<html lang=”en”>
<head>
<meta charset=”utf-8″>
<title>load demo</title>
<style>
body {
font-size: 12px;
font-family: Arial;
}
</style>
<script src=”https://code.jquery.com/jquery-1.10.2.js”></script>
<!– loading –>
<script src=”https://cdn.jsdelivr.net/jquery.loadingoverlay/latest/loadingoverlay.min.js”></script>
</head>
<body>

<b>Successful Response (should be blank):</b>
<div id=”success”></div>
<b>Error Response:</b>
<div id=”error”></div>

<script>
$.LoadingOverlay(“show”);
$( “#success” ).load( “E0301B2.php?usr=<?php echo $_GET[‘usr’]; ?>”, function( response, status, xhr ) {
if ( status == “error” ) {
$.LoadingOverlay(“hide”);
var msg = “Sorry but there was an error: “;
$( “#error” ).html( msg + xhr.status + ” ” + xhr.statusText );
}else{
$.LoadingOverlay(“hide”);
}
});
</script>

</body>
</html>