Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'database_connect.php';
- echo htmlhead("Home Page", "style.css");
- echo createNavMenu('');
- echo "<link rel='stylesheet' type='text/css' href='style.css' />";
- ?>
- <body>
- <br>
- <form class="form-horizontal" method="post" action="loginProcessScript.php">
- <div class="form-group">
- <label for="password">Enter your username:</label>
- <input type="username" name="username" class="form-control" placeholder="username"> </div>
- <div class="form-group">
- <label for="password">Enter your password:</label>
- <input type="password" name="password" class="form-control" placeholder="password"> </div>
- <div class="form-group">
- <button class="btn btn-primary btn-block" name="submit">Login</button>
- </div>
- </form>
- <div id='wrapper'>
- <h1>Starting jQuery Ajax</h1>
- <main>
- <h2>Books</h2>
- <article id="bookList">
- <h3>Book List</h3>
- <button id="getBooks">Retrieve Books</button>
- </article>
- </main>
- </div>
- <script type='text/javascript' src='js/libs/jquery-2.1.3.js'></script>
- <script type='text/javascript' src='js/jqtutAjax1.js'></script>
- <aside id="offers"> </aside>
- <br>
- <script>
- /* add a window load listener */
- window.addEventListener('load', function () {
- document.getElementById("offers").innerHTML = getRequest("/getOffers.php");
- });
- function getRequest(url) {
- var httpRequest;
- if (window.XMLHttpRequest) { // Mozilla, Safari, ...
- httpRequest = new XMLHttpRequest();
- }
- else if (window.ActiveXObject) { // IE
- try {
- httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
- }
- catch (e) {
- try {
- httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
- }
- catch (e) {}
- }
- }
- if (!httpRequest) {
- alert('Giving up :( Cannot create an XMLHTTP instance');
- }
- httpRequest.open('get', "/getOffers.php", true);
- httpRequest.onreadystatechange = function () {
- var completed = 4
- , successful = 200
- , returnValue;
- if (httpRequest.readyState == completed) {
- if (httpRequest.status == successful) {
- returnValue = httpRequest.responseText;
- return returnValue;
- }
- else {
- alert('There was a problem with the request.');
- }
- }
- }
- httpRequest.send(null);
- } // end of function getRequest
- </script>
- <?php
- echo createNavFooter('footer');
- echo"</body></footer></html>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement