Adding jquery inside external Javascript file

Adding jquery inside external Javascript file

Hi all,

I am new to jquery, and trying to add a reference to the jquery js file inside of an external javascript file (foo.js) through a document.writeln statement:

  1. document.write('<script language="javascript" src="http://code.jquery.com/jquery-1.5.min.js"><\/script>');
The issue I am finding is that my jquery calls inside of this foo.js file result in errors.

For example, adding the following jquery code to the end of foo.js results in "$ is not defined" error in chrome.

Here is my jquery code at the end of my foo.js file:

  1. $(document).ready(function() {
  2.   alert('here');
  3. });

Appreciate the help!