for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Mezon\Application;
/**
* Class AjaxMethodsTrait
*
* @package Application
* @subpackage AjaxMethodsTrait
* @author Dodonov A.A.
* @version v.1.0 (2019/09/27)
* @copyright Copyright (c) 2019, aeon.org
*/
* Base class of the ajax-application
trait AjaxMethodsTrait
{
* Validating authorization for ajax requests
* Must be overriden in the base class
abstract protected function validateAuthorizationForAjaxRequests();
* Method finishes ajax requests processing
protected function ajaxRequestSuccess()
print(json_encode([
"code" => 0
]));
die(0);
exit
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.
}
* Method finishes ajax requests processing and returns result
protected function ajaxRequestResult($result)
print(json_encode($result));
* @param string $message
* Error message
* @param int $code
* Error code
protected function ajaxRequestError(string $message, int $code = - 1)
"message" => $message,
"code" => $code
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.