Welcome Guest, Not a member yet? Register   Sign In
calling base_url() or site_url() in the external js file
#11

[eluser]xeroblast[/eluser]
sorry for a very late reply. my js script are external but im using the site_url() & base url() to that external script.

in your view header: include this script
Code:
<html>
<head>
<script type="text/javascript">
var js_site_url = function( urlText ){
var urlTmp = "<?php echo site_url('" + urlText + "'); ?>";
return urlTmp;
}
var js_base_url = function( urlText ){
var urlTmp = "<?php echo base_url('" + urlText + "'); ?>";
return urlTmp;
}
</script>
</head>
</html>
so when you need to call the site_url() or base_url() to your external js file, you just have to call js_site_url('codeigniter/url') or js_base_url('codeigniter/url')




Theme © iAndrew 2016 - Forum software by © MyBB