Jeedom Core

ajax
in package

Handles AJAX responses in Jeedom

Tags
example

ajax::init(['getInfos']); // returns void ajax::success(['result' => 'ok']); // sends JSON response

see
config::class

For configuration management

see
log::class

For logging management

Table of Contents

Methods

error()  : never
Sends an error response and ends execution
getResponse()  : string|false
Generates formatted JSON response
getToken()  : string
Returns authentication token
init()  : void
Initializes AJAX response with HTTP headers and GET action validation
success()  : never
Sends a success response and ends execution

Methods

error()

Sends an error response and ends execution

public static error([mixed $_data = '' ][, int $_errorCode = 0 ]) : never
Parameters
$_data : mixed = ''

Error message or data to send

$_errorCode : int = 0

Custom error code for client-side handling (default: 0)

Return values
never

getResponse()

Generates formatted JSON response

public static getResponse([mixed $_data = '' ][, int|null $_errorCode = null ]) : string|false
Parameters
$_data : mixed = ''

Data to include in response

$_errorCode : int|null = null

Error code (null for success response)

Return values
string|false

Encoded JSON response

getToken()

Returns authentication token

public static getToken() : string
Tags
deprecated

Since version 4.4, authentication is handled differently

Return values
string

Empty token

init()

Initializes AJAX response with HTTP headers and GET action validation

public static init([array<string|int, string> $_allowGetAction = array() ]) : void
Parameters
$_allowGetAction : array<string|int, string> = array()

List of allowed GET actions

Tags
throws
Exception

When requested GET action is not allowed

success()

Sends a success response and ends execution

public static success([mixed $_data = '' ]) : never
Parameters
$_data : mixed = ''

Data to send in response

Return values
never

        
On this page

Search results