title: How to reset bootstrap modal to its original contents on close?
body: <p>P.S I am not very good in javascript and I know this question has been asked but the solutions does not apply to my problem so I will ask this question again.</p>
  
  <p>I'm stuck with this problem and haven't find the solution yet. I wanted to clear all the things that happened into my modal after its close.</p>
  
  <p>My modal is a form modal, so whenever I click submit, codeigniter validation messages will show by the use of ajax on <code>&lt;div style="font-size:10px;width:50%;" id="info"&gt;&lt;/div&gt;</code> . Now whenever I close the modal, the validation messages stays when I re-open it. What should be done in order to clear those out after closing the modal?</p>
  
  <p>This is the function called by the ajax:</p>
  
  <pre><code>public function addcomp () {
    $this-&gt;load-&gt;library('form_validation');
    $this-&gt;load-&gt;helper('security');
    $this-&gt;form_validation-&gt;set_rules('comp_name','Computer Name','trim|required|callback_pc_exist');
    $this-&gt;form_validation-&gt;set_rules('status','Status','trim|required');
    $this-&gt;form_validation-&gt;set_rules('location','Location','trim|required');
  
    if ($this-&gt;form_validation-&gt;run()) {
  
      $this-&gt;load-&gt;model('asset_model');
      $result=$this-&gt;asset_model-&gt;addpc();
  
      if (!$result) {
        echo mysqli_error($result);
      } else {
        echo "&lt;div class='alert alert-success alert-dismissable'&gt;
        &lt;button type='button' class='close' data-dismiss='alert' aria-hidden='true'&gt;×&lt;/button&gt;
        Computer Successfully Added!&lt;/div&gt;";
      }
    }
    echo validation_errors("&lt;div class='alert alert-danger alert-dismissable'&gt;&lt;button type='button' class='close' data-dismiss='alert' aria-hidden='true'&gt;×&lt;/button&gt;","&lt;/div&gt;");
  }
  </code></pre>
  
  <p>This is the ajax called by submission:</p>
  
  <pre><code>$(document).ready(function(){
    $("#addpc").submit(function(){
      var formdata=$("#addpc").serialize();
      $.ajax({
        url:"asset_management/addcomp",
        type:"POST",
        data: formdata,
        async: true,
      }).done(function( formdata ) {
        $('#info').html(formdata);
        $("#addpc")[0].reset();
        viewdata();
      });
      return false;
    });
  });
  </code></pre>