I'm trying to search in an array of urls if there is a class name in any of the pages and get a new array with the urls that have thas class name.
This is what I have:
var urls = ["https://www.url.com/withclass","https://www.url.com/withoutclass"];
var classToFind=document.getElementsByClassName('empty');
var results = [];
function findClassURL(url, classempty){
jQuery.ajax({
url: url,
dataType: 'text',
type: 'GET',
complete: function(classname){
if(typeof classempty === 'function')
classempty.apply(this, [classname.all]);
}
});
}
for(var i = 0; i < urlsToSearch.length; i++) {
findClassURL(results.push(urlsToSearch[i]), function() {
if(all){
console.log(results + ' ok');
}
else {
console.log(urlsToSearch + ' has products');
}
});
}
Right now this gets me an 404 error.
Please help me to know if there is any other way of doing this
Thanks