title: duplicate page content after ajax to the same page
body: <p>I have simple registration formulae and I want I want to firstly send with ajax and without refreshing the page to control if I insert correct data and then just redirect to some other page. The problem is that after I send it through ajax to the same page everything is working but content of my page is being duplicate, I can see it twice... </p>
  
  <p>here is my ajax </p>
  
  <pre><code>function registruj () {
      var name = $('#meno').val();
      var priez = $('#priezvisko').val();
      var log  = $('#login').val();
      var mail  = $('#mail').val();
      var cisloTel  = $('#cislo').val();
      var heslo = $('#heslo').val();
      var heslo1 = $('#heslo1').val();
  
      $.post( "", {
              'meno': name,
              'priezvisko': priez,
              'login':log,
              'mail':mail,
              'cislo':cisloTel,
              'heslo':heslo,
              'heslo1':heslo1,
  
          }, function (data) {
              $('#result').html(data);
  
          }
  
  
      );
  
      $('#nove').load(document.URL + ' #nove');
  
  }
  </code></pre>
  
  <p>and this is my php file </p>
  
  <pre><code>&lt;?php
  
  session_start();
  if(isset($_POST["meno"]) ) {
      echo "kokot";
      echo $_POST['meno'];
      require "pripojenie.php";
      $meno = $_POST["meno"];
      $priezvisko = $_POST["priezvisko"];
      $login = $_POST["login"];
      $heslo = $_POST["heslo"];
      $hesloZnovu = $_POST["heslo1"];
      if(isset($_POST["pohlavie"]))
          $pohlavie = $_POST["pohlavie"];
      $mail = $_POST['mail'];
      $cislo = $_POST['cislo'];
      //$id = $_SESSION['id'];
  
  
  
  }
  ?&gt;
  
  &lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;blblblbl&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="./fancybox/jquery.fancybox-1.3.4.css" media="screen" /&gt;
      &lt;script src="jquery-1.4.3.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="./fancybox/jquery.mousewheel-3.0.4.pack.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="./fancybox/jquery.fancybox-1.3.4.pack.js"&gt;&lt;/script&gt;
      &lt;script&gt;$(function(){$('.img').fancybox();});&lt;/script&gt;
  
      &lt;style type="text/css"&gt; &lt;/style&gt;
  
      &lt;script type="text/javascript" src="mojskript.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" href="css/normalize.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/style1.css" /&gt;
  &lt;/head&gt;
  &lt;body  class="registracia"&gt;
  &lt;div class="container"&gt;
  
  &lt;div id="nove"&gt;
  
  
  
  
  
  
  
  
  
  
          &lt;form  &gt;
  
              &lt;table &gt;
                  &lt;tr&gt;&lt;td&gt;&lt;label for="napdis"&gt;Vyplňte nasledujúci formulár:&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
                  &lt;tr&gt;&lt;td&gt;&lt;input type="radio" name="pohlavie" value="zena" id="zena" &gt;Žena&lt;/td&gt;&lt;/tr&gt;
                  &lt;br&gt;
                  &lt;tr&gt;&lt;td&gt;&lt;input type="radio" name="pohlavie" value="muz" id="muz"&gt;Muž&lt;/td&gt;&lt;/tr&gt;
                  &lt;br&gt;
                  &lt;tr&gt;&lt;td&gt;&lt;label for="meno"&gt;Meno :&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;input type = "text" id="meno" name="meno"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;
                  &lt;tr&gt;&lt;td&gt;&lt;label for="priezvisko"&gt;Priezvisko :&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;input type = "text" id="priezvisko" name="priezvisko"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;
                  &lt;tr&gt;&lt;td&gt;&lt;label for="login"&gt;Login :&lt;/label&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type = "text" id="login" name="login"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;
  
                  &lt;?php
                  if(isset($heslo)) {
                      if (($heslo != "" &amp;&amp; $hesloZnovu != "") &amp;&amp; ($heslo == $hesloZnovu)) {
  
                          $hesloOk = 1;
                      }
                      else {
                          echo '&lt;tr&gt;&lt;td&gt;&lt;label for="heslo"&gt;Heslo :&lt;/label&gt;&lt;td&gt;&lt;input type = "password" name="heslo"&gt;&lt;/td&gt;&lt;td&gt;&lt;label for="zleHeslo"&gt;Heslá sa nezhodujú&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;';
                          $pocet = 1;
                      }
                  }
  
                  ?&gt;
                  &lt;?php
  
                  if(!isset($pocet)) {
  
                      echo'&lt;tr &gt;&lt;td &gt;&lt;label for="heslo" &gt; Heslo :&lt;/label &gt;&lt;/td &gt;
                      &lt;td &gt;&lt;input type = "password"  id="heslo" name = "heslo" &gt;&lt;/td &gt;&lt;/tr &gt;&lt;br &gt;';
                  }
                  ?&gt;
                  &lt;tr&gt;&lt;td&gt;&lt;label for="heslo2"&gt;Heslo znovu :&lt;/label&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type = "password"  id="heslo1" name="heslo1"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;
                  &lt;?php
                  if(isset($mail)) {
                      if (!stristr($mail, "@") OR !stristr($mail, ".")) {
                          echo '&lt;tr&gt;&lt;td&gt;&lt;label for="email"&gt;E-mail :&lt;/label&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;input type = "text"  name="email"&gt;&lt;/td&gt;&lt;td&gt;&lt;label for="zlyMail"&gt;Zlý formát emailu&lt;/label&gt;&lt;/td&gt;&lt;/rd&gt;&lt;/tr&gt;&lt;br&gt;';
                      } else {
                          $mailOk = 1;
                      }
                  }
                  else {
                      echo '&lt;tr&gt;&lt;td&gt;&lt;label for="email"&gt;E-mail :&lt;/label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type = "text" id="mail" name="email"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;';
  
                  }
  
                  ?&gt;
  
                  &lt;tr&gt;&lt;td&gt;&lt;label for="cislo"&gt;Telefónne číslo :&lt;/label&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type = "text" id="cislo" name="cislo"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;
                  &lt;tr&gt;&lt;td&gt;&lt;input type="button" value="Zaregistrovať" onclick="registruj()" &gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;/table&gt;
          &lt;/form&gt;
  
          &lt;?php
          if(isset($mailOk) &amp;&amp; isset($hesloOk)) {
              $length = 20;
  
              $randomString = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
  
  
              $zasifrovane = crypt($heslo,$randomString);
              echo $zasifrovane;
              mysql_query("INSERT INTO uzivatelia (Meno,Priezvisko,Login,Heslo,mail,pohlavie,cislo) VALUES ('$meno','$priezvisko','$login','$zasifrovane','$mail','$pohlavie','$cislo')");
              header("location:index.php");
          }
          ?&gt;
  
      &lt;/div&gt;
  
          &lt;div id="result"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>How should I do that ?</p>