title: Bootstrap successful alert in updating record Ajax
body: <p>I would like to use bootstrap alert in displaying success message in updating existing records. This is what I have:</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
    $(document).ready(function(){
        $("#submit_button").click( function() {
            $.post( $("#updateunit").attr("action"), 
              $("#updateunit :input").serializeArray(),function(info){ 
                $("#result").html(info); 
            });
        });
        $("#updateunit").submit( function() {
            return false;   
        });
    });
    function clearInput() {
      $("#updateunit :input").each( function() {
        $(this).val('');
      });
  }  
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;div class="control-group"&gt;
                  &lt;label class="control-label" for="transaction"&gt;Notes&lt;/label&gt;
                  &lt;div class="controls"&gt;
                    &lt;textarea rows="3" columns="10" name="notes"&gt;&lt;?php echo $notes; ?&gt;&lt;/textarea&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="control-group"&gt;
                  &lt;div class="controls"&gt;
                  &lt;button class="btn btn-custom" type="submit" id="submit_button"&gt;Update&lt;/button&gt;
                  &lt;a href="#" class="back"&gt;&lt;button class="btn btn-custom" onclick="goBack()"&gt;Back&lt;/button&gt;&lt;/a&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
  
              &lt;/form&gt;
              &lt;div id="result" class="alert alert-success"&gt;&lt;/div&gt;
            &lt;/div&gt;
  </code></pre>
  
  <p><strong>edit.php</strong></p>
  
  <pre><code>  &lt;?php
  include('../../db.php');
  if( isset($_POST['reservation_code']) || isset($_POST['transaction_code'])   ){
        $transaction_id = $_POST['transaction_id'];
        $reservation_code = $_POST['reservation_code'];
        $transaction_code = $_POST['transaction_code'];
        $notes = $_POST['notes'];
  
        $update = $conn-&gt;prepare("UPDATE tblunitreservation 
              SET reservation_code = :reservation_code,
              transaction_code = :transaction_code,
              notes = :notes
              WHERE transaction_id = :transaction_id");
        $update-&gt;execute(array(':reservation_code' =&gt; $reservation_code, 
                          ':transaction_code' =&gt; $transaction_code,
                          ':notes' =&gt; $notes,
                          ':transaction_id' =&gt; $transaction_id));
          echo 'Successfully updated record!';
  } else {
          echo 'Required field/s is missing';
  }
  ?&gt;
  </code></pre>
  
  <p>I want the alert message to be in the centre of the screen but what happening is that when I do not update the record, the alert background is visible and then I update the record that is only the time the message Successfully update appears.</p>