-
Notifications
You must be signed in to change notification settings - Fork 34
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 $scriptscript 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 $messageThe error message -
bool $abort_handlingAbort 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 $scriptJS code as string or array -
bool $abort_handlingAbort 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 $dataData 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_handlingAbort clientside success/error handling
Let the client redirect.
Definition: public static function Redirect($controller, $event, $data)
Returns: AjaxResponse The created response
Parameters:
-
mixed $controllerThe controller to be loaded (can be Renderable or string) -
string $eventThe event to be executed -
mixed $dataOptional 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 $contentContent to be passed out -
bool $force_dependency_loadingIf 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 $textText to be passed out