Hi
i want to use javascript file in my javascript code, i use $.getScript to dynamically load javascript file in application, when i use registerScriptFile in controller to registerScript file $.getScript can’t get data of javascript file but when i use javascript file url it work well.
//use js file in js code
$.getScript("/FleetManagement/index.php/history", function(data, textStatus, jqxhr) {
console.log(data);
});
//history index action
public function actionIndex()
{
/*$this->registerFiles();
$this->render('index');*/
$assetDir = Yii::getPathOfAlias('application.assets');
$assetUrl = Yii::app()->assetManager->publish($assetDir.'\history',false,-1,false);
Yii::app()->clientScript->registerScriptFile( $assetUrl.'/fleethistory.js',NULL);
}
above code doesn’t work!
$.getScript("/FleetManagement/js/history/fleethistory.js", function(data, textStatus, jqxhr) {
console.log(data);
});
above code work well and log data of js file to console.
how can i do this work with yii framework?
i want to render script like giving url of js file.