Guest User

Untitled

a guest
Jan 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>teste ajax</title>
  5. </head>
  6. <body>
  7. <div id="resposta">
  8.  
  9. </div>
  10.  
  11. <script
  12. src="https://code.jquery.com/jquery-3.3.1.js"
  13. integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
  14. crossorigin="anonymous"></script>
  15. <script >
  16. $(document).ready( function(){
  17.  
  18. $.get( "teste.txt" , function(dados, status, xhr) {
  19. $("#resposta").text(dados);
  20. } );
  21. } );
  22.  
  23.  
  24. </script>
  25.  
  26. </script>
  27. </body>
  28. </html>
  29.  
  30. <!DOCTYPE html>
  31. <html>
  32. <head>
  33. <title>teste ajax</title>
  34. </head>
  35. <body>
  36. <div id="resposta">
  37.  
  38. </div>
  39.  
  40. <script>
  41.  
  42. var resposta = document.getElementById("resposta");
  43. var xmlHttp;
  44.  
  45. if (window.XMLHttpRequest) {
  46. xmlHttp = new XMLHttpRequest;
  47. }
  48. else {
  49. xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  50. }
  51.  
  52.  
  53. xmlHttp.onreadystatechange = function(){
  54. if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
  55. resposta.innerHTML = xmlHttp.responseText;
  56. }
  57.  
  58. }
  59.  
  60. xmlHttp.open('GET', 'teste.txt', true);
  61. xmlHttp.send();
  62.  
  63. </script>
  64.  
  65.  
  66. </script>
  67. </body>
  68. </html>
  69.  
  70. test
  71.  
  72. test123
Add Comment
Please, Sign In to add comment