I'm making these ajax requests from a Google Chrome extension which I'm trying to create, but every time my extension makes a request it gets cancelled. I don't know why.
This snippet below works fine.
function makeRequest(method, url){
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.djjohal.com");
xhr.send();
}
setTimeout(makeRequest, 10000)
But when I change the above code to this, it didn't work.
var submit = document.querySelector('input[type=submit]')
submit.addEventListener('click', callback)
function makeRequest(method, url){
var xhr = new XMLHttpRequest();
xhr.open(method, url);
xhr.send();
}
function callback(){
makeRequest('GET', 'http://www.djjohal.com')
}
What am I doing wrong?