How to add an external javascript file to a Zend Framework 2 application?

javascript, jquery, zend-framework, zend-framework2

Solution

 $this->HeadScript()->appendFile('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js','text/javascript');
 $this->HeadScript()->appendFile('http://localhost/zend/public/js/validate_jquary.js','text/javascript');

It is OK with this code in the view. But I don't know is this correct method.

Problem

I need to add jQuery and other javascript files to my Zend Framework project. I am trying to do it with an Action controller:- ``` public function userinfoAction() { $this->view->headScript()->appendFile($basePath .'/js/validate_jquary.js'); $this->headScript()->appendFile('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'); return new ViewModel(); } ``` But it is not working.

Original source