Interface for AJAX elements in various pages.

Load the class through FACTORY: $this->ajax = FACTORY_AJAX::getInstance();

version 1.0
author Mark Grimshaw
package wikindx4\core\ajax

 Methods

AJAX

__construct() 

Convert JSON-formatted $jsonString to an array or object.

decode_jString(string $jsonString, boolean $stripslashes, boolean $array) : mixed

Parameters

$jsonString

string

The JSON string

$stripslashes

boolean

In WIKINDX, querystrings are slashed. Default is TRUE.

$array

boolean

If TRUE (default), return associative array, otherwise return object.

Returns

mixedArray or object

Convert $jsonArray to JSON string and format any array elements referencing javascript functions.

encode_jArray(array $jsonArray, boolean $quote) : string

Parameters

$jsonArray

array

The unformatted JSON array

$quote

boolean

No encoding of quotation marks (") if set to FALSE. Default is FALSE.

Returns

stringThe JSON string

Create and load the HTML form element insert for the AJAX action and function.

jActionForm(string $action, array $jsonArray, boolean $return) 

Parameters

$action

string

The javascript action such as 'onclick' etc.

$jsonArray

array

The parameter to be passed to gateway() as an array ready to be converted to JSON

$return

boolean

If TRUE, generated javascript has a return from the gateway() function. Default is FALSE.

Create and load the IMG element insert for the AJAX action and function.

jActionIcon(string $icon, string $action, array $jsonArray, boolean $return) : string

Works with core/display/LOADICONS.php.

Parameters

$icon

string

The icon to make an image of ('add', 'delete', 'view' etc.)

$action

string

The javascript action such as 'onclick' etc.

$jsonArray

array

The parameter to be passed to gateway() as an array ready to be converted to JSON

$return

boolean

If TRUE, generated javascript has a return from the gateway() function. Default is FALSE.

Returns

stringThe image tag

Load the ajax javascript and the user javascript(s) into the HTML page output.

loadJavascript(mixed $scripts) 

Parameters

$scripts

mixed

Either an array of .js scripts to load or a single string. It can be FALSE.

Encode JSON string to UTF8.

jsonMap(string $value) 

Parameters

$value

string

echo JSON error or return if none.

json_error(string $type) 

Parameters

$type

string