Last active
January 4, 2016 17:19
-
-
Save matherton/8653161 to your computer and use it in GitHub Desktop.
AJAX demo that loads a PHP script once the request has completed. I use MAMP but any server running APACHE and PHP would be fine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <link rel="stylesheet" href="custom-booking-search.css"> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> | |
| </script> | |
| <script> | |
| $(document).ready(function(){ | |
| $(document).ajaxStart(function(){ | |
| $("#plane-border").css("display","block"); | |
| }); | |
| $(document).ajaxComplete(function(){ | |
| $("#plane-border").css("display","none"); | |
| }); | |
| $("button").click(function(){ | |
| $("#txt").load("loading.php"); | |
| }); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| <div id="txt"><h2>Let AJAX change this text</h2></div> | |
| <button>Change Content</button> | |
| <div id="plane-border" style="display:none;"> | |
| <h1>Loading,<br>Please wait</h1> | |
| </div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #plane-border { | |
| width: 260px; /*can be in percentage also.*/ | |
| height: 260px; | |
| margin: 0 auto; | |
| padding: 10px; | |
| position: relative; | |
| border: 4px solid #552286; | |
| padding: 4px; | |
| outline: 4px solid #a41681; | |
| box-shadow: | |
| 0 0 0 8px #ce79b9, | |
| 0 0 0 13px #ececec; | |
| margin-bottom: 15px; | |
| margin-top: 15px; | |
| text-align: center; | |
| } | |
| h1 { | |
| color: #652384; | |
| font-size: 35px; | |
| background: url(images/loading.gif) no-repeat center 100px; | |
| padding: 240px 0 30px 0; | |
| position: relative; | |
| top: -75px; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| echo "<h2>AJAX has loaded</h2>"; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment