title: reload a div without reloading the whole page using ajax/jquery
body: <p>I'm doing a project which needs to be refreshed when user finish the form which is in the same page. Here is the code:</p>
  
  <p>page1.jsp</p>
  
  <pre><code> &lt;div id="codeRefer"&gt;
      &lt;input type="" type="text" name="numcode" id="numcode" value="42988715"&gt;
      &lt;script language="javascript"&gt;
          var a = Math.ceil(Math.random() * 9) + '';
          var b = Math.ceil(Math.random() * 9) + '';
          var c = Math.ceil(Math.random() * 9) + '';
          var d = Math.ceil(Math.random() * 9) + '';
          var e = Math.ceil(Math.random() * 9) + '';
          var f = Math.ceil(Math.random() * 9) + '';
          var g = Math.ceil(Math.random() * 9) + '';
          var h = Math.ceil(Math.random() * 9) + '';
          var code = a + b + c + d + e + f + g + h;
          document.getElementById("numcode").value = code;
  
          function ValidCaptcha() {
              var str1 = removeSpaces(document.getElementById('numcode').value);
              var str2 = removeSpaces(document.getElementById('txtInput').value);
              if (str1 == str2) {
                  return true;
                  alert(str1);
              } else {
                  return false;
              }
          }
  
          function removeSpaces(string) {
              return string.split(' ').join('');
          }
      &lt;/script&gt;
  &lt;/div&gt;
  &lt;input type="button" value="REFRESH" onClick="javascript:refer()"&gt;
  &lt;script language="javascript"&gt;
      function refer() {
          $('#codeRefer').load(window.location.href + '#codeRefer');
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Here what I'm getting is when ever I click the refresh the textbox value gets refreshed but, I'm getting another same 'refresh' button at the bottom of the first refresh button.
  I don't know why an another button appears. Thankyou guys!</p>
  
  <pre><code>I think there is a bug in my code.
  Which keeps repeating the whole content whenever I press the REFRESH button.
  HELP me with this guys GURU'S.
  </code></pre>