ping

Network

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,

  1. code - {Integer}. HTTP status code.  Contains 0 if the server is not reachable.
  2. result - {Boolean}. Reachability status of the server.
  3. error - {Object}. The error object contains,
  1. message - {String}. A short description of the error.
  2. description - {String}. A detailed description of the error.

timeout

number (optional)

Timeout in seconds before the  host is reached. Default value is 5 seconds.