ajax.submitAs

Since: Editor 2.5

Set the data parameter submission format.
Please note - this property requires the Editor extension for DataTables.

Description

When making an Ajax request, there are times which you might wish to submit the data to the server as a JSON string. This is particularly useful in .NET which can easily parse the JSON for you, or in cases with values such as null are important. This option provides that ability.

This option matches the ajax.submitAs option in DataTables core, providing the same functionality, just in this case for the Editor Ajax interaction.

As of Editor 2.5.2, when set to json, the ContentType header for the request will automatically be set to be application/json; charset=utf-8, unless a value has already been specified.

Please note that the provided PHP, .NET and Node.js server-side libraries for Editor do not expect this option to be set - they use the default http parameter method.

Type

string

This option can take one of the following values:

  • http: Submit the data as individual HTTP parameters (default, used if undefined)
  • json: Submit the data as a JSON string.

Default

  • Value: http

Example

Submit data as a POST with JSON in the request body:

const editor = new DataTable.Editor({
	ajax: {
		url: '/api/staff',
		submitAs: 'json'
	},
	fields: [
		/* ... */
	],
	table: '#myTable'
});

Related

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