I’m trying to make a ajax call to one method in my Notification controller.
My method is:
public function testeAjax()
{
if($this->chamadaAjax())
echo 'Ajax';
else
echo 'Form';
}
The $this->chamadaAjax() simply perform and $this->input->is_ajax_request()
And this is my Ajax call:
$.ajax({
type: "POST",
url: '<?php echo base_url(); ?>/office/notificacao/testeAjax',
success: function(html) {
alert(html);
}
});
I have a form with two buttons, one for form submit and another for ajax request.
The thing is that when I add some data to the ajax like: data: “nome=Gerep”, and call it, I receive a Internal Erro 500
When I don’t send any data, it works, it returns me form when submitted and ajax when I call ajax request.
Any ideas?
EDIT
Using FireBug here is what I get:
f.support.ajax.f.ajaxTransport.sendjquery-1.7.1.min.js:4
f.extend.ajaxjquery-1.7.1.min.js:4
testenotificacao:140
(anonymous function)notificacao:113
onclick
The problem was with Cross Site Request Forgery, disabling it solved the problem.