post

issues a POST AJAX request to the server

promise post(string url, [object params,function callback] );

Parameters

urlstringthe URL to load
paramsobjectthe hash of parameters to send to the server
callbackfunctionoptional callback function

Returns

promisedata "promise" object with result parsing methods

Example

webix.ajax().post('data.php', { filter : '123' }).then(function(data){
    // response
    console.log(data.text());
});

Details

Callback

The callback function takes 3 parameters:

  • text - the full text of the response
  • data - the object with methods for getting data as plain text, JSON, and XML
  • xhr - an xmlHttpRequest object

Return value

The method returns a promise object than contains the eventual result of the AJAX request. You can use the promise instead of the callback, and access the result argument, which will have the following methods:

  • json() - return the result parsed as JSON
  • xml() - return the result parsed as XML
  • rawxml() - return the raw XML data
  • text() - return the plain text of the result
webix.ajax().post('data.php', { filter : '123' }).then(function(result){
    console.log(result.json());
}).fail(function(xhr){
    var response = JSON.parse(xhr.response);
    webix.message({type: 'error', text: response.error.message});
});

More information on Webix and Promiz.js usage can be found at:

See also
Back to top