classes_base_ajaxresponse.class

Daniel Spors edited this page May 8, 2014 · 5 revisions
Clone this wiki locally

Classes in file base/ajaxresponse.class.php

class AjaxResponse

Helper class to easily create standard AJAX responses.

Namespace: ScavixWDF\Base

AddScript

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::script() 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: void

Parameters:

  • array|string $script script code or array of script codes to be added.

Error

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

Js

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

Json

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

None

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

Redirect

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)

Reload

Let the client reload the current page.

Definition: public static function Reload()

Returns: AjaxResponse The created response

Render

INTERNAL Renders the response for output.

Renderable

Return a Controller (with full init-code).

Definition: public static function Renderable(Renderable $content)

Returns: AjaxResponse The created response

Parameters:

  • Renderable $content Content to be passed out

Text

Return a plain text.

Definition: public static function Text($text=false)

Returns: AjaxResponse The created response

Parameters:

  • string $text Text to be passed out