Advertisement
Guest User

Untitled

a guest
Dec 7th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. <?php
  2. require_once 'database_connect.php';
  3.  
  4. echo htmlhead("Home Page", "style.css");
  5. echo createNavMenu('');
  6. echo "<link rel='stylesheet' type='text/css' href='style.css' />";
  7.  
  8. ?>
  9.  
  10. <body>
  11. <br>
  12. <form class="form-horizontal" method="post" action="loginProcessScript.php">
  13. <div class="form-group">
  14. <label for="password">Enter your username:</label>
  15. <input type="username" name="username" class="form-control" placeholder="username"> </div>
  16. <div class="form-group">
  17. <label for="password">Enter your password:</label>
  18. <input type="password" name="password" class="form-control" placeholder="password"> </div>
  19. <div class="form-group">
  20. <button class="btn btn-primary btn-block" name="submit">Login</button>
  21. </div>
  22. </form>
  23. <div id='wrapper'>
  24. <h1>Starting jQuery Ajax</h1>
  25. <main>
  26. <h2>Books</h2>
  27. <article id="bookList">
  28. <h3>Book List</h3>
  29. <button id="getBooks">Retrieve Books</button>
  30. </article>
  31. </main>
  32. </div>
  33. <script type='text/javascript' src='js/libs/jquery-2.1.3.js'></script>
  34. <script type='text/javascript' src='js/jqtutAjax1.js'></script>
  35. <aside id="offers"> </aside>
  36. <br>
  37. <script>
  38. /* add a window load listener */
  39. window.addEventListener('load', function () {
  40. document.getElementById("offers").innerHTML = getRequest("/getOffers.php");
  41. });
  42.  
  43. function getRequest(url) {
  44. var httpRequest;
  45. if (window.XMLHttpRequest) { // Mozilla, Safari, ...
  46. httpRequest = new XMLHttpRequest();
  47. }
  48. else if (window.ActiveXObject) { // IE
  49. try {
  50. httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
  51. }
  52. catch (e) {
  53. try {
  54. httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
  55. }
  56. catch (e) {}
  57. }
  58. }
  59. if (!httpRequest) {
  60. alert('Giving up :( Cannot create an XMLHTTP instance');
  61. }
  62. httpRequest.open('get', "/getOffers.php", true);
  63. httpRequest.onreadystatechange = function () {
  64. var completed = 4
  65. , successful = 200
  66. , returnValue;
  67. if (httpRequest.readyState == completed) {
  68. if (httpRequest.status == successful) {
  69. returnValue = httpRequest.responseText;
  70. return returnValue;
  71. }
  72. else {
  73. alert('There was a problem with the request.');
  74. }
  75. }
  76. }
  77. httpRequest.send(null);
  78. } // end of function getRequest
  79. </script>
  80. <?php
  81. echo createNavFooter('footer');
  82. echo"</body></footer></html>";
  83.  
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement