title: jQuery callback function not executed
body: <p>I have a contact form with a few input fields and a div that acts as a button - when I click on it, it calls for a function that validates the form and if everything is OK it submits it. The function sends the data from the inputs to a <code>API.php</code> file, which calls for a sending function in the <code>BusinessLogic.php</code> file. Once the form is submitted - a callback function should be activated and it should animate a confirmation div.</p>
  
  <p>The HTML of the inputs:</p>
  
  <pre><code>&lt;div id="contact_inputs_block"&gt;
      &lt;div class="div_contact_form_input_box div_input_name"&gt;
          &lt;input type="text" name="Name" placeholder="* Name" id="name"&gt;
      &lt;/div&gt;
      &lt;div class="div_contact_form_input_box div_input_phone"&gt;
          &lt;input type="tel" name="Phone" placeholder="* Phone" id="phone"&gt;
      &lt;/div&gt;
      &lt;div class="div_contact_form_input_box div_input_email"&gt;
          &lt;input type="email" name="Email" placeholder="* Email" id="email"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form_confirmation_wraper"&gt;
      &lt;div id="div_form_confirmation"&gt;
          Message sent.
      &lt;/div&gt;
      &lt;div class="div_send_form"&gt;
  
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here's my function:</p>
  
  <pre><code>function submit_form(language)
  {   
  
  var email_str = $("#email").val();
  var errors = new Array();
  
  $("#contact_inputs_block&gt;div:not(:last-child)").css({'border-color' : '#a5957e', 'background-color' : '#f8f8f8'});
  
  
  if ($("#name").val()=="")
  {
      errors.push(".div_input_name");
  }
  if(!validate_email(email_str))
  {
      errors.push(".div_input_email");
  }
  if ($("#phone").val()=="")
  {
      errors.push(".div_input_phone");
  }
  
  
  if (errors.length == 0)
  {
  
  
      $.getJSON("inc/API.php",
      {
          command : "send_contact_form",
          name : $("#name").val(),
          email : email_str,
          phone : $("#phone").val(),
          message : $("#message").val().replace(/\n/g, '&lt;br&gt;'),
          form_language: language
      } ,function(){
          alert("sent");
          $("#div_form_confirmation").animate({opacity:1}, 1000, function(){
              setTimeout($("#div_form_confirmation").animate({opacity:0}, 3000, function(){location.reload()}),6000);
          }); // end callback function
      }); // end getJSON
  } // end if
  else
  {
      for (var i = 0; i &lt;= errors.length; i++)
      {
          $(errors[i]).css({'border-color' : '#E60005', 'background-color' : '#ffc4c9'});
      }
  }
  }
  </code></pre>
  
  <p>this is the function in API.php:</p>
  
  <pre><code>include_once 'BusinessLogic.php';
  session_start();
  
  $command = $_REQUEST["command"];
  
  switch($command)
  {
      case "send_contact_form" :
          send_contact_form($_REQUEST["name"], $_REQUEST["email"], 
              $_REQUEST["phone"], $_REQUEST["message"], $_REQUEST["form_language"]);
          break;
  }
  </code></pre>
  
  <p>and the BusinessLogic.php actually sends the mail.</p>
  
  <p>The mail is being sent, everything is OK there. The problem is the callback of submit_form() function is never fired and I don't see the confirmation that the mail was sent.</p>
  
  <p>Why is it happening and how do I fix it? Thanks!</p>