title: Ajax And Spring MVC
body: <p>Hey Guys Am trying to update the jsp page by using ajax response here my issue is </p>
  
  <p>i have one dropdown ,It contains some values ,each value is associated with the some certain data,if i select one value from dropdown then i'll get the corresponding data on the jsp page ,If i try to select Another value from dropdown ,then jsp page contains the old as well as new data ,But actually i want new data ,once new data comes old data on jsp page shouls vanishes out from the page</p>
  
  <p>here my ajax call code is </p>
  
  <pre><code>function getSubjects(sectionId) {
  
  
  
  
          $.ajax({
  
              type : 'get',
              url : approoturl+'/admin/section/subjects?sectionId='+sectionId,
  
              success : function(response) {
  
  
  
                        var table = $('&lt;table class="table table-bordered"/&gt;').appendTo($('#somediv'))
                                                                              .append($('&lt;th/&gt;').text("Subject Name"))
                                                                              .append($('&lt;th/&gt;').text("Language"))
                                                                              .append($('&lt;th/&gt;').text("Subject ID"))
                         $(response).each(function(i, response) {
                                      $('&lt;tr/&gt;').appendTo(table)
                                                .append($('&lt;td/&gt;').text(response.name))
                                                .append($('&lt;td/&gt;').text(response.language))
                                                .append($('&lt;td/&gt;').text(response.id));
                         }); 
  
  
              }
          });
  
  
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>and my jsp page is </p>
  
  <pre><code>&lt;div id="form-group-section-id"
                          class="form-group col-md-4 col-md-offset-4"&gt;
                          &lt;label class="control-label"&gt;Choose Class&lt;/label&gt;
                          &lt;form:select cssClass="form-control" path="section.id"
                              onchange="getSubjects(value);"&gt;
                              &lt;form:option value="${-1}"&gt;Select Class&lt;/form:option&gt;
                              &lt;c:forEach items="${sections}" var="section"&gt;
                                  &lt;form:option value="${section.id}"&gt;${section.name}&lt;/form:option&gt;
                              &lt;/c:forEach&gt;
                          &lt;/form:select&gt;
                          &lt;div class="text-danger"&gt;
                              &lt;form:errors path="section.id" /&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
  
                      &lt;div id="somediv"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Please give me some tips to remove old data and populate new data to particular div "somediv"
  any help would be greatfull</p>