Can someone explain why I cannot get the desired delay between each request?
They all happen at once.
$(window).load(function(){ $('a[href]').each(function(){ var linkk = $(this) var linkkhref = linkk.attr('href'); window.setTimeout(function(){ conectar('HEAD', linkkhref, resp) }, 2000) function conectar(metodo, endereco, resposta, corpo) { callback = function(xhr) { resposta(xhr) }; GM_xmlhttpRequest({ "method" : metodo, "url" : endereco, "onerror" : callback, "onload" : callback, "headers" : {'Content-Type':'application/x-www-form-urlencoded'}, "data" : corpo }); }; function resp(responseDetails) {
I know im using a special Greasemonkey function, but the question is about javascript.
No GM knowledge required. :)
javascript
RASG
source share