Checks the reachability of the specified host.
$m.ping("http://www.cloudpact.com", function(response){ if(response.code!=0){ $m.toast("Successfully reached the host"); } else{ $m.toast(response.error.message); } }); |
Syntax
$m.ping(hostName [,fp_callback, timeout])
Parameters
hostName
string(required)
Name of the host to check for reachability. The name should contain the url scheme like http://.
fp_callback
function (optional)
Function to execute after the reachability check is done. The function receives a response object as parameter, with the following properties,
- code - {Integer}. HTTP status code. Contains 0 if the server is not reachable.
- result - {Boolean}. Reachability status of the server.
- error - {Object}. The error object contains,
- message - {String}. A short description of the error.
- description - {String}. A detailed description of the error.
timeout
number (optional)
Timeout in seconds before the host is reached. Default value is 5 seconds.