I have a quite complicated problem: I use the PHP Simple HTML DOM Parser to fetch some price data from different webshops. The data is shown on my website. The problem is that I need data from about 10 shops with about each 50 products. So about 500 links all in all. The Links are retrieved from an CSV. I want it like this: Open the csv -> retrieve the link -> parse the price data from the link -> show it on the website
My first try was this:
var file = 'shops.csv';
Papa.parse(file, {
delimiter: ";",
download: true,
header: false,
dynamicTyping: true,
complete: function(results) {
$.each(results.data, function(i, item){
$.ajax({
type: 'POST',
url: "parser.php",
data: {url:item[4]},
success: function(data,status){
if(data){
var output = '<a href="'+item[4]+'" target="_blank">' + data +'</a>';
$('table tbody tr[data="'+item[1]+item[3]+'"] td').append(output);
}
},
async:true
});
});
}
});
Now all links are parsed synchronous which crashes the server. When the ajax call is done asynchronous the data is only shown when the last call is done. The perfect way should be step by step... get the link -> get the price -> show the price -> next.