[eluser]JulianM[/eluser]
I like this idea. Thanks.
I was using a different approach, but I think I will change for this approach. Before, I was using a <a href="<?php echo site_url() ?>ajax.php" id="ajax"> in the view and then in the javascript file (jQuery) I did something like this: $('ajax').attr('href') to retrieve the ajax function to use.
[quote author="inparo" date="1220339580"]I usually have a general javascript view that defines an object literal with a few constants. Just put that in front of all your other scripts.
Code:
</script type="text/javascript">
<!--
var CI = {
'base_url': '<?php echo site_url(); ?>/',
'blab': '<?php echo $something_my_js_needs; ?>'
};
//-->
</script>
Then, to call a url:
Code:
var url = CI.base_url + 'some/url/goes/here';
[/quote]