My first post of these forums :)
This is to work in a mobile browser (android in this case). I need to check if a computer is on before I know which function to use.
Is there a way I can ping it so as to determine it's network presence and run an according function? For now, I just have messages for testing. (navigator.notification.alert is the Cordova method for displaying messages on a mobile device)
I've sort of made up this code, is there any way to get this to work, I've done a bit of Googling to no avail.
Please note that this is to work on a local network.
function isOn() {
$.ajax({
url : 'http://192.168.x.xxx' , //x.xxx being the client ip
success : function () {
navigator.notification.alert(
'The computer is on.', //Message body
alertDismissed, //Callback
'The Computer is On', //Title
'Yes' //Button Label
);
},
error : function () {
navigator.notification.alert(
'The computer is off.', //Message body
alertDismissed, //Callback
'The Computer is Off', //Title
'Yes' //Button Label
);
}
});
};
<a onclick="isOn();">Test</a>