post

sends a POST AJAX request to the server

promise post(string url, [object params,function callback] );
urlstringthe URL to load
paramsobjectthe object with parameters to send to the server
callbackfunctionoptional callback function
promise"promise" of the object with the methods for getting data

Example

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

Details

Callback

The callback function receives 3 parameters:

  • text - the full text of the response from the server
  • 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. A promise can be used instead of callbacks. The function inside the then() of a promise receives the result parameter - the object that has 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