Documentation

BX.ajax.runAction

BX.ajax.runAction(action[, config])

BX.ajax.runAction is the method to launch ajax actions in module that returns BX.Promise. In case the csrf token has expired, it will attempt to restore it (only one attempt is made) and repeat the query. If receives query from server, which has status not equal to success - promis is rejected.

Parameters

Parameter Description Available from version
action {string} Action to be launched. For example, disk.folder.get.
config {Object} Parameters:
  • data {Object|FormData} Object with data to be sent in query body с данными. The same as in BX.ajax.
  • json {Object} - object with data to be passed in query body. Has specified contentType: application/json, and controllers can access original JSON which allows to conveniently handle numerals and empty values.
  • navigation {Object} - page navigation object.
    • page {number} - page number. Count starts from 1.
    • size {number} - page size (from 1 to 50). By default 20.
  • analyticsLabel {string|Object} - optional parameter is used as tag for analytics hits.
  • method {string} - optional. By default, POST.

Example

BX.ajax.runAction('disk.folder.get', {
	data: {
		folderId: 1 
	},
	analyticsLabel: {
		viewMode: 'grid',
		filterState: 'closed'	
	}
}).then(function (response) {
	console.log(response);
	/**
	{
		"status": "success", 
		"data": {
			"ID": 1,
			...
		}, 
		"errors": []
	}
	**/			
}, function (response) {
	//here the location to receive all responses with status !== 'success'
	console.log(response);
	/**
	{
		"status": "error", 
		"errors": [...]
	}
	**/				
});

© «Bitrix24», 2001-2022
Up