Currently, I am working on a JavaScript code that alerts the count in an array of pages.
The variable urls represents an array of page names, while count contains the count value.
My goal is to alert the count value for each page in the urls array.
However, I'm facing an issue with the for loop not executing every time. I'm unsure why this is happening... Can someone please assist me in identifying the mistake?
I have been using echo $_POST['suggest'];
within the array of pages. However, I would like to receive and alert the 'suggest' value using JavaScript instead. How can I achieve this through JavaScript?
<script>
$(document).ready(function () {
var count = document.getElementById('display_visitor_number').innerHTML; //count
var urls = document.getElementById('display_visitor_urls').innerHTML; //array of page names
var myarr = urls.split(",");
for (var i=1;i<myarr.length;i++)
{
$.post(myarr[i],{suggest:count}, function(data) {
alert(data);
});
}
});
</script>