Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <html>
  2. <head><title>Simple Ajax</title>
  3. <script type="text/javascript">
  4. function ajaxFunction() {
  5. var xmlHttp;
  6. var p = document.getElementById("id1");
  7. try { // Firefox, Opera 8.0+, Safari
  8. xmlHttp = new XMLHttpRequest();
  9. } catch (e) { // Internet Explorer
  10. try {
  11. xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  12. } catch (e) {
  13. try {
  14. xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  15. } catch (e) {
  16. alert("Your browser does not support AJAX!");
  17. return false;
  18. }
  19. }
  20. }
  21. xmlHttp.onreadystatechange = function () {
  22. if (xmlHttp.readyState == 4) {
  23. p.innerHTML = xmlHttp.responseText;
  24. }
  25. }
  26. xmlHttp.open("GET", "txt.txt", true);
  27. xmlHttp.send(null);
  28. }
  29. </script>
  30. </head>
  31. <body>
  32. <div><input type="button" value="Zmień tekst" onclick="ajaxFunction()";" /></div>
  33. <p id = "id1">Ten tekst zostanie zmieniony przez AJAX !</p>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement