Use Javascript File In Javascript Code

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.

They reference two different urls.

Do you have a History action? If so what does it do?

Yeah, they use different urls because i can’t use js file with action i input it js folder of application and use it!

I paste my history controller action( actionIndex ) in the first code. Can you see it?

In this action i only need to render js file with


jQuery.getScript( url [, success(script, textStatus, jqXHR)] )

it use url of js file and in the action i only need to send content of js file to jQuery.getScript success function to use it’t data.