title: Why doesn't '$.each' seem to work?
body: <p>When I have the following inside the same HTML document it seems to work:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  datasets[0] = {
      "buildnames": {
          label: "buildnames",
          data: ["test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a5", "test2-a6"]
      }
  };
  
  function doSomething() {
      var i = 0;
      for (var j = 0; j &lt; datasets.length; j++){
          $.each(datasets[j], function(key, val) {
              val.color = i;
              ++i;
          });
  
          var choiceContainer = $("#choices");
          //var testkey = new RegExp("cover");
          $.each(datasets[j], function(key, val) {
              if (key.indexOf("failed") &gt; -1 || key.indexOf("cover") &gt; -1) {
                  choiceContainer.append('&lt;br /&gt;&lt;input type="checkbox" name="' + key +
                  '" checked="checked" id="id' + key + '"&gt;' +
                  '&lt;label for="id' + key + '"&gt;'
                  + val.label + '&lt;/label&gt;');
              }
          });
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>But when I'm exporting this to a separate JavaScript file and then importing it and call the function like this</p>
  
  <pre><code>&lt;script type="text/javascript" language="Javascript" src="root/include/graph_1.js"&gt;&lt;/script&gt;
  
  &lt;a href="javascript:doSomething()"&gt;doSomething&lt;/a&gt;
  </code></pre>
  
  <p>I get the following error: '<code>$</code>' is undefined  and points at "<code>$.each(..</code>"
  So why can't I use this function is I "export" all JavaScript code in an HTML document to another separate JavaScript file?</p>
  
  <p><em><strong></em>**<em>*</em>**<em>*</em>**<em>*</em>**</strong><em>edit</em><strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>*</strong></p>
  
  <p>I tried the tips below  and changed the order</p>
  
  <p>@idbentley I did what you said and changed the order of those 2 so it is</p>
  
  <pre><code>    &lt;script language="javascript" type="text/javascript" src="root/include/jquery.js"&gt;&lt;/script&gt;
      &lt;script language="javascript" type="text/javascript" src="root/include/jquery.flot.js"&gt;&lt;/script&gt;
      &lt;script language="javascript" type="text/javascript" src="root/include/jquery.flot.crosshair.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" language="Javascript" src="root/include/graph_1.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But now I get another error "Exception thrown and not caught" Anyone know what this error means?</p>