classes_base_ajaxresponse.class
Helper class to easily create standard AJAX responses.
Allows addition of scripts to responses. Sometimes it is useful to add JS codes for immediate execution. In plain HTML request this would be done with for example Control() which adds the script to the parent pages init method, but for AJAX requests we need to go this way.
Definition: public function AddScript($script)
Returns: self
Parameters:
-
array|string $script
script code or array of script codes to be added.
Return an error. If $abort_handling is true the clietside error handling will not be polled
Definition: public static function Error($message, $abort_handling=false)
Returns: AjaxResponse The created response
Parameters:
-
string $message
The error message -
bool $abort_handling
Abort clientside success/error handling
Return just script code to be executed clientside immetiately. If $abort_handling is true the clientside success/error handling will not be polled
Definition: public static function Js($script=false, $abort_handling=false)
Returns: AjaxResponse The created response
Parameters:
-
mixed $script
JS code as string or array -
bool $abort_handling
Abort clientside success/error handling
Return data JSON formatted ($data can be anything!).
Definition: public static function Json($data=null)
Returns: AjaxResponse The created response
Parameters:
-
mixed $data
Data to be passed out
This is a valid Noop return.
Definition: public static function None($abort_handling=false)
Returns: AjaxResponse The created response
Parameters:
-
bool $abort_handling
Abort clientside success/error handling
Let the client redirect.
Definition: public static function Redirect($controller, $event, $data)
Returns: AjaxResponse The created response
Parameters:
-
mixed $controller
The controller to be loaded (can be Renderable or string) -
string $event
The event to be executed -
mixed $data
Optional data to be passed (string or array)
Let the client reload the current page.
Definition: public static function Reload()
Returns: AjaxResponse The created response
INTERNAL Renders the response for output.
Return a Controller (with full init-code).
Definition: public static function Renderable(Renderable $content, $force_dependency_loading=null)
Returns: AjaxResponse The created response
Parameters:
-
Renderable $content
Content to be passed out -
bool $force_dependency_loading
If false, stops automatic JS/CSS dependency search and delivery
Return a plain text.
Definition: public static function Text($text=false)
Returns: AjaxResponse The created response
Parameters:
-
string $text
Text to be passed out