Hi I'm trying to use an external js, the and I'm using Yii clienScript :
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/some.js');
The problem is, in my external js file, I need to pass a url, for my ajax call. and the url is in php, because I'm using the createAbsoluteUrl() below :
$url = Yii::app()->createAbsoluteUrl("/module/controller/action")
How do I pass the $url as a javascript variable to be used by some.js? Thanks!
You could create a JS object at the end of your PHP code.
Then the javascript file some.js should be able to use this as:
I have done this on CodeIgniter - I'm assuming Yii works similar.