I\'m having some issues with ajax and codeigniter. I\'ve already posted another question (link to question) and I thought I solved it, but I did not so I`m asking someone to wri
If you are using this ajax in a .php file than you should do something like this to your url:
function increase(){
var number = parseInt($('#number').html()) + 1;
var base_url = "";
$.ajax({
type: 'POST',
url: base_url+'welcome/increase',
data: { increase:number },
success:function(response){
$('#number').html(response);
}
});
}
OR if you are doing this in a .js file than you need to add this line inside your head tag
And than use this :
function increase(){
var number = parseInt($('#number').html()) + 1;
$.ajax({
type: 'POST',
url: base_url+'welcome/increase',
data: { increase:number },
success:function(response){
$('#number').html(response);
}
});
}
Hope that it resolves the problem. However, its always a good idea when developing in the local environment to set the base_url in config.php like this :
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;