0

Like add an event listener to the xmlhttp object page and add the url to an array,so I can save all the url's,it shows up in the network tab of the web inspector,so if the page makes a http get,I have the url added to an array

thanks

armando
  • 67
  • 8
  • http://stackoverflow.com/questions/7775767/javascript-overriding-xmlhttprequest-open my question got answered here the facebook function,thanks Jakob for your help,I guess I was poor at phrasing my question,thanks – armando Jun 22 '16 at 02:50

1 Answers1

0

You could do something like this:

HTML

<input type="text" id="url">
<button id="submit">submit</button>

JS

var urlInput = document.getElementById("url");
document.getElementById("submit").addEventListener("click", function(){
    request(urlInput.value);
    urlInput.value = null;
});

var urls = [];
function urlPush(u){
  urls.push(u);
  console.log(urls);
}

function request(dataURL) {
  var xmlhttp = new XMLHttpRequest();
  var url = dataURL;

  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      urlPush(url);
    }
  }

  xmlhttp.open("GET", url, true);
  xmlhttp.send();
}

With this you insert URL in input and on success URL is pushed to array which you can see in console on submit.

I created similar functions for some of my projects so here you can test and inspect extended code for it with additional array of URLs for what you need.

Jakob
  • 3,493
  • 4
  • 26
  • 42