post

Http

Sends a POST request to the specified url.

$m.post("www.cloudpact.com", "Welcome to cloudpact", function(response){

   if(response.code == 200){

      $m.toast(response.result);

   } else{

      $m.toast(response.error.message);

   }

});

Syntax

        $m.post(url, data  [,fp_callback])

        $m.post(url ,data [,options, fp_callback])

Parameters

Url

string (required)

The url to which the request must be sent.

data

string/object (required)

String data or key-value pair data to post. String data should be received as stream at the server side.

fp_callback

function (optional)

The function that is invoked after the request has been executed. The function receives the response object which contains the following properties,

  1. code - {Number}. 0 if the request failed to fire due to malformed url or network error, otherwise the http status code sent by the server.

  1. result - {Object}. The result contains the following properties,
  1. headers - {Object}. The response headers received from the server.
  2. data - {String}. The response data received from the server.

  1. error - {Object}. If code is 0, the error contains the properties,
  1. message - {String}. The error message.
  2. description - {String}. The error description in detail if any.

options

object (optional)  

Optional parameters object for the request. It can contain one or more of the following properties,

  1. headers - {Object}. The headers to be set for the request. Default value is {}

  1. timeout - {Number}. The timeout of the request in milliseconds. If the response is not received from the server within timeout period, the request will be cancelled and timeout error will be thrown.