Skip to navigation
Get the base url into javascript global jquery name space and delete the last forwardslash from the url
25.06.15
in my body tag i have the php code what set the base_url: base_url(),'lang'=>$lang ]) ?>' 2. in my js file i'm getting and setting this data to the global jquery namespace: jQuery(document).ready(function () { jQuery.global = {}; jQuery.global.data = JSON.parse(document.getElementsByTagName('body')[0].getAttribute("data-js") ); jQuery.global.url = jQuery.global.data.base_url.substr(0,jQuery.global.data.base_url.lastIndexOf("/")); });
http://www.w3schools.com/jsref/jsref_substr.asp
Reply
Anonymous
Information Epoch 1732573893
Save trees.
Home
Notebook
Contact us