Intermediate

Saving Data with Ajax Helper

Webix Ajax helps save component data, form and input data on demand.

Note that DataProcessor isn't initialized this time and you need to catch the necessary events (add, edit, delete) yourself. For forms saving, a request is usually sent on a button click.

Data are sent to a server script in the body of an Ajax POST request:

webix.ajax().post("myscript", params);

Note that

  • params are sent in the form of a JSON object which is exactly what the form's getValues method returns:
webix.ajax().post("my_script", {id: some, name: some, address:some });
webix.ajax().post("my_script", form.getValues());

Additionally, you can pass extra parameters as a GET request:

webix.ajax().post("data/load.php?id=1&action=update", {
    prop1:value1, prop2:value2
}).then(function(data){
    // some actions with data
});

Here is what you might have in a server-side script:

$id = $_GET['id'];
$action = $_GET['action'];
$prop1 = $_POST['prop1];
$prop2 = $_POST['prop2];

Learn more about the possibilities of Webix Ajax interface.

Back to top