title: Submit form using JS and AJAX
body: <p>I have little problem with JS and AJAX, i dont know this languages. I know php and i have applied for position php developer, now i have some tasks to do and i stucked at one. It is simple task, form, submit, process information, store in DB, and send. Only problem is i have to use AJAX to submit form, i done little research and somehow i made wrote this code but it doesnt work.</p>
  
  <pre><code>&lt;div&gt;
          &lt;form method="POST" action="add.php" id="form"&gt;
              &lt;input type="email" name="email" id="email" value="Email"&gt;
              &lt;textarea name="content" id ="content"&gt;Message&lt;/textarea&gt;
              &lt;input type="submit" value="Submit" id="submit"&gt; 
          &lt;/form&gt;
          &lt;a href="send.php"&gt;Send messages from database&lt;/a&gt;
      &lt;/div&gt;
      &lt;script&gt;
          $(document).ready(function() {
              // When click on button store values from form fields into variables
              $("form").submit(function(event) {
                  event.preventDefault();
                  var email = $("#email").val();
                  var content = $("#content").val();
                  // Check if fields are empty 
                  if (email=="" || content="") {
                      alert("Please fill all fields");
                  }
                  // AJAX code to submit form
                  else {
                      $.ajax ({
                          type: "POST",
                          url: ("#form").attr('action');
                          data: { "email": email, "content": content},
                          cache: false,
                          success: function() {
                              alert("Data successfully forwarded to add.php");
                          }
                      });
                  }
                  return false;
              });
          });
      &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>IN form can i use input type button instead of submit (so no need for preventDefault in JS) and in JS i do it 
  $("#submit").click(function.....</p>
  
  <p>I think i have tried all combinations and when form is submited it goes with default, no JS activated... </p>
  
  <p><strong>SOLVED:</strong> problem was in IF statment, content="" instead of content=="", OMG how i overlooked that...</p>