I am working with codeigniter and jquery ajax. I'm having some incosistencies b/w my app locally on wamp (working perfectly) and my deployed app (not so much). Once possible suggested fix is to convert ajax relative paths to absolute paths for ajax, so it looks like:
url: "YOURBASEPATH/AjaxController/update",
location.href = "YOURBASEPATH/pan_controller/my_detail";
Following Convert ajax relative paths to absolute paths with codeigniter I have changed my code to :
In your header section just add the following script.
<script type="text/javascript">
var BASE_URL = "<?php echo base_url();?>";
</script>
$.ajax({a
type: "POST",
url: BASE_URL+"AjaxController/update",
data:{ i : searchIDs, m : message },
dataType: 'json',
.done(function() {
alert("REFRESHING..");
location.href = BASE_URL+"pan_controller/my_detail";
});
}
})
I thought this would work but for some reason BASE_URL is not being recognized as a variable and instead of seeing for eg:
url: "YOURBASEPATH/AjaxController/update",
I see:
url: BASE_URL+ "/AjaxController/update",
When I look at the source.
I'm not seeing any errors in my editor. Any ideas why this is not working?
edit:
case "Set":
var message = $('#send_message').val()
if (searchIDs.length>0){
console.log(BASE_URL+ "Update/update");
$.ajax({
type: "POST",
url: BASE_URL+"Update/update",
data:{ i : searchIDs, m : message },
dataType: 'json',
.done(function() {
alert("REFRESHING..");
location.href = BASE_URL+"pan_controller/detail";
});
})
} else { alert("nothing checked") }
break;