title: JavaScript/jQuery - "$ is not defined- $function()" error
body: <p>I am trying to run a JavaScript/jQuery function and <a href="http://en.wikipedia.org/wiki/Firebug_%28software%29" rel="noreferrer">Firebug</a> gets the error:</p>
  
  <pre><code>$ is not defined $(function()".
  </code></pre>
  
  <p>The JavaScript code is placed inside a file called <code>core.js</code> and referenced by <code>index.php</code>. What causes this error?</p>
  
  <p><strong>JavaScript:</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var formObject = {
          run : function(obj) {
              if (obj.val() === '') {
                  obj.nextAll('.update').html('&lt;option value=""&gt;----&lt;/option&gt;').attr('disabled', true);
              } else {
                  var id = obj.attr('id');
                  var v = obj.val();
                  jQuery.getJSON('/mod/update.php', { id : id, value : v }, function(data) {
                      if (!data.error) {
                          obj.next('.update').html(data.list).removeAttr('disabled');
                      } else {
                          obj.nextAll('.update').html('&lt;option value=""&gt;----&lt;/option&gt;').attr('disabled', true);
                      }
                  });
              }
          }
      };
  
      $(function() {
  
          $('.update').live('change', function() {
              formObject.run($(this));
          });
  
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>PHP/HTML</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;select name="main" id="category" class="update"&gt;
      &lt;option value=""&gt;Select one&lt;/option&gt;
  
          &lt;? if (!empty($list)) { ?&gt;
              &lt;? foreach($list as $row) { ?&gt;
                  &lt;option value="&lt;?php echo $row['id']; ?&gt;"&gt;
                      &lt;? echo $row['name']; ?&gt;
                  &lt;/option&gt;
  
              &lt;? } ?&gt;
          &lt;? } ?&gt;
  
      &lt;/select&gt;
  &lt;/html&gt;
  </code></pre>