Advertisement
Samardziev

lab3-1

Jan 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <body>
  2. <div id="d1">
  3.     <label for="inp1">Vnesi URL:</label><input type="text" id="inp1" style="width:350px;">
  4.     <button onclick="getData();">Get Content</button>
  5. </div>
  6. <div id="d2"></div>
  7. <script>
  8.     function getData() {
  9.         var link;
  10.         link=document.getElementById("inp1").value;
  11.         var newlink=link.split("/");
  12.         newlink=newlink[newlink.length-1];
  13.         console.log(newlink);
  14.         var link=document.getElementById("inp1").value;
  15.  
  16.         var xhttp=new XMLHttpRequest();
  17.         xhttp.open("GET",newlink,true);
  18.         xhttp.send();
  19.         xhttp.onreadystatechange = function(){
  20.             if(xhttp.readyState==4 && xhttp.status==200){
  21.                 document.getElementById("d2").innerHTML=xhttp.responseText;
  22.             }
  23.         }
  24.     }
  25. </script>
  26. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement