ajax()

Since: Editor 1.8

Get / set the Ajax configuration for the Editor.
Please note - this property requires the Editor extension for DataTables.

Description

The ajax() method can be used to alter the Ajax configuration that an Editor instance uses - for example to change the target URL. It can also be used to obtain the current Ajax configuration which will match the value given to ajax (or this method if used as a setter), allowing for programmatic checking of the Ajax configuration.

Please note, that if you wish to alter the data submitted to the server, rather than using this method use preSubmit or ajax.data which are both evaluated on each Ajax request that Editor makes.

Also be aware that this method will completely replace the existing Ajax configuration for the Editor instance. For example if you currently have it configured with an object, but use a string to update the URL, the object will be replaced with the string. You would need to either read the object from the method as a getter and then modify as required before setting again, or pass in a new object.

Types

ajax()

Get the current Ajax configuration

Returns:

string or object:
The value returned is the value given to ajax, or if this method was used as a setter, the value used to set the Ajax configuration.

ajax( conf )

Set the Ajax configuration. This matches the ajax options.

Parameters:

Returns:

DataTable.Editor: Editor instance

Example

Change the URL for submission:

editor.ajax('/api/users/' + userId);
// where usedId comes from an external method - e.g. a drop down for other variable

Related

The following options are directly related and may also be useful in your application development.