I am trying to use jQuery ajax in Codeigniter. In previous projects I already used jQuery ajax but this time I am getting problems. Below is my code
$.ajax({
type:"POST",
url:"<?php echo base_url()?>register",
data:{
name:$("#f_name").val()
},
cache:false,
success:function(result){
$("#registration_result").html(result);
alert("success");
},
error:function(){
alert("fail");
}
});
Here the problem is even I am not getting the Error message "Fail". Please let me know if I am doing anything wrong here.
Please check your register page url, maybe the page is not found, so ajax fall into error-function,
error:function(){
alert("<?php echo base_url()?>register");
alert("fail");
}
when your ajax running it will alert "url register", then please open that url, to check if the page is exist or not.
If the register-page is not exist,
Check value of "index_page" application/config/config.php
$config['index_page'] = 'index.php';
If the value is "index.php", change your ajax-url into
url:"<?php echo base_url()?>index.php/register",