AJAX in combination with captcha
Permalink
Hello!
My problem seems to be simple:
I use a form (containing a captcha) which is submitted asynchronously using ajax.
An AJAX delivers the form's contents to a controller method.
Captcha validation does obviously not work now, just take a look at the code below:
View from where controller method is called. AJAX request works fine.
The relevant controller functions:
Obviously, there is no reference to the captcha-object anymore when receiving the ajax-request. But if I create a new one, the old captcha code is invalid.
Ideas, anybody?
Thanks in advance,
Julian
My problem seems to be simple:
I use a form (containing a captcha) which is submitted asynchronously using ajax.
An AJAX delivers the form's contents to a controller method.
Captcha validation does obviously not work now, just take a look at the code below:
View from where controller method is called. AJAX request works fine.
<form> <?php $this->controller->captcha->display(); $this->controller->captcha->showInput(); ?> </form> <a id="buttonNewPost" href="<?=$saveNewPost?>">Send</a>
The relevant controller functions:
defined('C5_EXECUTE') or die(_("Access Denied.")); Loader::helper('validation/captcha'); class xyzController extends BlockController { public $captcha; /** * On Start **/ public function on_start() { $this->captcha = new ValidationCaptchaHelper(); } /** * Called from view.php **/
Viewing 15 lines of 30 lines. View entire code block.
Obviously, there is no reference to the captcha-object anymore when receiving the ajax-request. But if I create a new one, the old captcha code is invalid.
Ideas, anybody?
Thanks in advance,
Julian