webCOMAND

\io_comand_web\ajax

An ajax object encapsulates getting an AJAX request and setting and updating a response object to send back to a client.  It also can send logged data.

Example

The following example retrieves parameters sent with the AJAX request, performs an action and sends a response.

// Send an email in response to an AJAX request
$ajax = new \io_comand_web\ajax();

$to = $ajax->request->to;
$subject = $ajax->request->subject;
$message = $ajax->request->message;

$result = \io_comand_email\mail::mail($to, $subject, $message);

$ajax->ok(['result' => $result]);

Properties

The following properties can be accessed as $this->property, where property is one of the following.

  • request - The request object used to access HTTP query parameters, etc.
  • <parameter> - All other property names can be used to set and get previously set HTTP response parameters as a shortcut to the get() and set() methods.