• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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')


Messages In This Thread
calling base_url() or site_url() in the external js file - by El Forum - 07-05-2013, 11:57 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.