title: jQuery .get function sending request multiple times
body: <p>I have the following code in my head area:</p>
  
  <pre><code>&lt;script&gt;
  $(function() {
      $("#idNameHere").click(function() {
          var title = $("#threadTitle").val();
          var category = $("#category").val();
          var message = CKEDITOR.instances['message'].getData();
  
          errors = new Array();
          if (title == "")
              errors.push("\n\t- You must enter a title.");
          if (category == "")
              errors.push("\n\t- You must select a category.");
          if (message == "")
              errors.push("\n\t- You must enter a message.");
  
          if (errors.length &gt; 0)
          {
              var errorString = "Please fix the following errors and try again:";
              for (var i = 0; i &lt; errors.length; i++)
                  errorString = errorString + errors[i];
  
              alert(errorString);
          }
          else
          {
              $.get("./ajax/createThread.php", { title: title, category:category, message: message }, function(data) {
                  if (!isNaN(data))
                      window.location='./viewThread.php?tid='+data;
                  else
                      alert(data);
              });
          }
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Sometimes (but not always) it sends the request multiple times - so I end up with thread objects being inserted into my database in multiples.</p>
  
  <p>From what I've read, it's because the click function is within the $(function() {}); area - However, if i take the click function out of that area, the click event isn't caught and the code isn't run at all.</p>
  
  <p>How can I get the click function to register, and ONLY run once?</p>