title: Jquery If condition display message based on submission or failure
body: <p>Im learning Jquery and AJAX on my own through online tutorials and by posting on SO when I gets stuck, so please keep in mind I am a novice should you be so kind to answer my question.</p>
  
  <p>I have a form inside a modalbox. Ajax prevents it from closing/reloading and a message gets displayed after submission as you can see in image below:</p>
  
  <p><img src="https://i.stack.imgur.com/dVLE2.png" alt="enter image description here"></p>
  
  <p><strong>My problem</strong></p>
  
  <p>Both the success and failure messages gets displayed. I would like to change this so that 1) Success message gets displayed on successfull submission or 2) failure message gets displayed on failed submission:</p>
  
  <p><strong>My Form</strong></p>
  
  <pre><code> &lt;div id="inline3" style="width:400px;display: none;"&gt;
          &lt;h3&gt;Contact Us&lt;/h3&gt;
          &lt;form name="message-form" action="" id="contact-form" method"post"&gt;
          Message&lt;br /&gt; &lt;input type="text" name="msg" value="" /&gt;&lt;br /&gt;
          &lt;input type="submit" value="Contact Us" name="contact" class="buttono" /&gt;
          &lt;/form&gt;
          &lt;div class="form-feedback" style="display:none"&gt;
          Thank You We will Get Back to you 
          &lt;/div&gt;
           &lt;div class="form-feedback" style="display:none"&gt;
          Ooops....Something Went Wrong
          &lt;/div&gt;
         &lt;div&gt; 
  </code></pre>
  
  <p><strong>JQUERY</strong></p>
  
  <pre><code>$(function(){
      $("#contact-form").submit(function(e){
      e.preventDefault(); 
  
      $form = $(this);
  
      $.post(document.location.url, $(this).serialize(), function(data){
          $feedback = $("&lt;div&gt;").html(data).find(".form-feedback").hide();
          $form.prepend($feedback)[0].reset();
          $feedback.fadeIn(1500)
      })
  
      });
  })
  </code></pre>
  
  <p>If anyone can give me a bit of help or advise here it will be greatyly appreciated.</p>
  
  <p>Thanks for reading</p>