I have a Matrix table generated in PHP. And I want to show a "check" or a "cross" based on result of a DNS call. This table Matrix can contain more than 200.000 cells.
I've tried to put all PHP code on same page, but the PHP go timeout if there are many DNS calls to do. I moved on to ajax. Added a DIV inside each cell and put the ajax code calling a 2nd PHP which will do the DNS query. This works well, but after 5000-6000 requests, some cells aren't populated. My guess is because the script is trying to make calls for all cells at the same time.
Is it a way to get ajax doing calls for each cell one at time?
I have this PHP code:
$body .= '
<script type="text/javascript">
';
foreach (getEachIpInRange($cidr) as $IP) {
foreach ($rbls as $rbl) {
$divid++;
$body .= ' function updatediv' . $divid . '() {
$.ajax({
type: \'get\',
url: \'verify.php?ip=' . $IP . '&dns=' . $rbl . '\',
data: $(self).serialize(),
success: function(data) {
$("#div' . $divid . '").html(data).text();
}
})
}
';
}
}
$body .= ' </script>
';
That generates the following code:
<script type="text/javascript">
function updatediv1() {
$.ajax({
type: 'get',
url: 'verify.php?ip=123.123.123.123&dns=host.domain1.tld',
data: $(self).serialize(),
success: function(data) {
$("#div1").html(data).text();
}
})
}
function updatediv2() {
$.ajax({
type: 'get',
url: 'verify.php?ip=234.234.234.234&dns=host.domain2.tld',
data: $(self).serialize(),
success: function(data) {
$("#div2").html(data).text();
}
})
}
function updatediv3() {
$.ajax({
type: 'get',
url: 'verify.php?ip=345.345.345.345&dns=host.domain3.tld',
data: $(self).serialize(),
success: function(data) {
$("#div3").html(data).text();
}
})
}
function updatediv4() {
$.ajax({
type: 'get',
url: 'verify.php?ip=456.456.456.456&dns=host.domain4.tld',
data: $(self).serialize(),
success: function(data) {
$("#div4").html(data).text();
}
})
}
The best would be a single function that will update each cell one after the other. But if not possible, how can I loop between all functions and run them, giving like 25ms or 30ms of interval between each of them to not get a timeout?