I'm trying to do an ajax request with jquery and codeigniter framework, but when I try to access to the server page, I have a forbidden access.
Here's my jquery code :
$('#btHello').click(function () {
var name = $('#name').val();
alert(name);
$.ajax({
type:'POST',
data:'name='+ name,
url:'<?php echo base_url();?>index.php/AjaxTest/ajaxtest',
success: function(result, status){
$('#result1').html(result);
},
error: function (result, status, error) {
alert(error);
}
});
});
The error alert just shows "Forbidden", nothing more.
Does anyone know what is the problem ?
Here's the controler :
class AjaxTest extends CI_Controller {
public function index() {
$this->load->view('home/head');
$this->load->view('home/nav');
$this->load->view('test/ajaxTest');
$this->load->view('home/foot');
}
public function ajaxTest(){
$name = $this->input->post('name');
echo 'Hello '.$name;
}
}