postJSON

This method can be used to retrieve a JSON result sending data to the server via POST encoding. This method works just like jQuery's native $.getJSON(), but uses POST to send the data parameters.

$.postJSON(url, data, cb, ecb, opt)

Usage

$.postJson("sendData",{ name: "Rick", company: "West Wind" },
           function sendData_sucess(result) {
               // do something with result value 
           },
           function sendData_error(error) {
                console.log(error.message);
           })

Returns

jQuery Promise Object

Parameters

url
The URL to invoke with the request. Url can include query string values.

data
Either a string of raw POST data, or an object map of values that are turned into POST variables.

For example: { name: "Rick",total:"5.99" } is serialized into two POST variables named name and total with values of Rick and 5.99 as strings.

cb and ecb
These are the callback and error callback respectively. The callback receives the result data from the server, the error callback an error object with a message property.

opt
These are HttpClient options. The ones that are applied by this function are:

var options = { 
    method: "POST",
    contentType: "application/x-www-form-urlencoded",
    noPostEncoding: true,
    evalResult: true
}
$.postJSON(url,data,cb,ecb)

Class Members

See also:

Class postJSON

© West Wind Technologies, 1996-2018 • Updated: 02/01/16
Comment or report problem with topic