Metoda generujaca captche i widok z kontrolerze o nazwie Ajax_Controller:
public function add_comment() { $this->template = new View('App/tab_template'); $this->template->content =new View('App/elements/comment'); $this->template->content->captcha = new Captcha; if($_POST) { if ( Captcha::valid($this->input->post('captcha_response'))) { }else { } } $this->template->render(true); }
Widok comment:
<div id="add_comment_wrapper"> <?php } ?> </div> <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $("#valid_form").submit(function(e){ e.preventDefault(); var captcha = $("input[name='captcha_response']").val(); $.ajax({ type: "POST", data:"captcha_response="+captcha, async: true, success: function(msg) { $('#add_comment_wrapper').html(msg); }, error: function(msg) { alert('error2'); } }); }); }); </script>
proszę nie zwracać uwagi na prostote, chodzi o test poki co , moim zamiarem jest po wyslaniu posta ajaxem ponownie wczytac medote add_comment wrac z widokiem i NOWA captcha..(jest ciagle ta sama)
ps. dziala jak pomiedzy postami usune sesje recznie, ale juz nie dziala jak usune w kodzie.. nic z tego nie rozumiem prosze o pomoc!