I want to ping servers and get the online status of that server with JQuery $.post() method. My current code:
JQuery:
$(window).load(function() {
$.post('php/ping_server.php', { 'domains[]': ["example.com", ..., ...] }, function(status) {
for (var i=0; i < status.length; i++) {
$('.sidebox .onlinestatus').eq(i).addClass(status[i]).text(status[i]);
}
}, "json");
});
PHP:
include('functions.php');
if (isset($_POST["domains"])) {
$status = array();
foreach($_POST["domains"] as $domain) {
$status[] = pingDomain($domain);
}
die(json_encode($status));
}
The function pingDomain() returns "Offline" or "Online" and it works.
I'm not getting any errors or warnings in the console but nothing happens...
What is wrong?
'domains[]': ["example.com", ..., ...]is wrong do'domains': ["example.com", ..., ...]console.log(status)in you jquery recieve method, then tell us if it prints what it should.