Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <!-- urządzenia mobilne -->
  5. <!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
  6. <!-- wymuszenie na IE aby używał najnowszej wersji silnika renderującego stronę -->
  7. <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
  8. <meta charset="utf-8">
  9. <title>DIV 2</title>
  10. </head>
  11. <body>
  12.  
  13. <div id="demo">
  14. <h2>XMLHttpRequest Object</h2>
  15. <button type="button" onclick="f1()">Pobierz treść</button>
  16. </div>
  17.  
  18. <script>
  19. function f1() {
  20. var xhttp = new XMLHttpRequest();
  21. xhttp.onreadystatechange = function() {
  22. if (this.readyState == 4 && this.status == 200) { //4 -żądanie zakonczone, odpowiedz serwera gotowa; 200 - OK
  23. document.getElementById("demo").innerHTML =
  24. this.responseText; //jako tekst JS //responseXML - jako XML
  25. }
  26. };
  27. xhttp.open("GET", "ajaxplik.txt", true); //open(method, url, async) //GET (proste w użyciu)/POST //url pliku //true - asynch. false synch.
  28. xhttp.send(); //wysyła żądanie do serwera
  29. }
  30. </script>
  31.  
  32. </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement