title: Ajax not working properly when I tried to call it on same page again
body: <p>I have a PHP page which has two sections (top and bottom). The top section has a table where I have options to Edit the data. </p>
  
  <p>Once the Edit button is pressed, the content is loaded at the bottom of page and the user can change the data.</p>
  
  <p>Here is part of my PHP page:</p>
  
  <pre><code>            &lt;div id="product_entry_&lt;?php echo $id?&gt;" class="product_entry_&lt;?php echo $id?&gt;"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;font size=2px&gt;&lt;?php echo $date?&gt;&lt;/font&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;font size=2px&gt;&lt;?php echo $ProductName?&gt;&lt;/font&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;font size=2px&gt;&lt;?php echo $Category.' / '.$SubCategory?&gt;&lt;/font&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;font size=2px&gt;&lt;?php echo $MRP.' / '.$Price?&gt;&lt;/font&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;button type="submit" class="btn btn-primary btn-xs" style="padding:2px 2px;font-size: 9px;line-height: 10px;" onClick="DirectPromoteSubmit(&lt;?php echo $id?&gt;)"&gt;Promote&lt;/button&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;button type="submit" class="btn btn-primary btn-xs" style="padding:2px 2px;font-size: 9px;line-height: 10px;" onClick="RePromoteSubmit(&lt;?php echo $id?&gt;)"&gt;Edit&lt;/button&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;button type="submit" class="btn btn-primary btn-xs" style="padding:2px 2px;font-size: 9px;line-height: 10px;" onClick="DelPromoteSubmit(&lt;?php echo $id?&gt;)"&gt;X&lt;/button&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/div&gt;
  
              &lt;!-- page where data is loaded --&gt;
              &lt;div class="box box-warning" id="RePromoteReplace"&gt;
               ....some html content here...
              &lt;/div&gt; 
  </code></pre>
  
  <p>Here is my Javascript:</p>
  
  <pre><code>            function RePromoteSubmit(id){
                  //alert('got into Edit Promotions');
                  var dataString = "id="+ id;
                  alert(dataString);
                  if(dataString=='')
                  {
                      alert('Some Problem Occurred, Please try Again');
                  }
                  else
                  {
                  //alert('into post');
                  $.ajax({
                      type: "POST",
                      url: "SellerPanel/post_repromote.php",
                      data: dataString,
                      cache: false,
                      success: function(html){
                          //$("#tweet").val('');
                          //$("#preview").hide();
                          $("#RePromoteReplace").replaceWith(html);
                          alert('Product Successfully Loaded!!! Edit(Optional) &amp; Click Promote Button in bottom section')
                      }
                      });
                  }return false;
                  } 
  </code></pre>
  
  <p>Here is my PHP page which loads the bottom section - post_repromote.php:</p>
  
  <pre><code>            &lt;?php
              include("../dbconnection.php");
              include("session.php");
              if(!isset($_SESSION))
              {
                  session_start();
              }
  
              $id=$_POST['id'];
  
              $query1=mysqli_query($con,"select promotiondata from sellerpromotions where id=$id");
              while($row=mysqli_fetch_array($query1))
                  {
                  .....some code here.....
                  }
              ?&gt;
                          &lt;div class="box box-warning"&gt;
                              &lt;div class="box-header"&gt;
                              &lt;h3 class="box-title"&gt;Fill Product Details&lt;/h3&gt;
                              &lt;/div&gt;&lt;!-- /.box-header --&gt;
                              &lt;div class="box-body"&gt;
  
                          &lt;!-- &lt;form role="form " name="PromoteForm"&gt; --&gt;
                          &lt;div&gt;
                                  &lt;!-- text input --&gt;
                              &lt;table class="table"&gt;
                                  ....some data here from query..
                              &lt;/table&gt;        
  
                              &lt;div class="box-header with-border"&gt;
                                          &lt;h3 class="box-title"&gt;Upload your Product Image&lt;/h3&gt;
                              &lt;/div&gt;&lt;!-- /.box-header --&gt;
                              &lt;div class="box-body no-padding"&gt;
                                  &lt;div id='preview'&gt;
                                      &lt;?php if ($uploadid){ ?&gt;
                                          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;img src=&lt;?php echo "SellerPanel/uploads/".$imagename?&gt; id="&lt;?php echo $uploadid?&gt;" alt="User Image" class='preview' style='width:340px;height:200px;border-color:black'/&gt;
                                      &lt;?php } 
                                      ?&gt;
                                  &lt;/div&gt;    
                                  &lt;?php 
  
                                      include ("index_photo.php");
  
                                  ?&gt;
  
                                  &lt;!-- &lt;span class="users-list-date"&gt;Yesterday&lt;/span&gt; --&gt;
  
                              &lt;/div&gt;&lt;!-- /.box-body --&gt;
                              &lt;div class="box-footer"&gt;
                                  &lt;button type="submit" class="btn btn-primary" onClick="PromoteSubmit()"&gt;Promote&lt;/button&gt;
                              &lt;/div&gt;
                      &lt;/div&gt;
                              &lt;/div&gt;&lt;!-- /.box-body --&gt;
                          &lt;/div&gt;&lt;!-- /.box --&gt;
              &lt;?php }
              ?&gt;
  </code></pre>
  
  <p>The problem I'am facing:</p>
  
  <ul>
  <li>I'am able to load the data when I press the Edit button first.</li>
  <li>When I press it again, I'm not able to load the new data unless I refresh the page and click the Edit button again.</li>
  </ul>
  
  <p>I tried to read the id in JS and printed it, I found that id is being passed correctly.</p>
  
  <p>Any help would be very much appreciated.</p>
  
  <p>Thanks in advance!</p>
  
  <p>JS after using solution:</p>
  
  <pre><code>            function RePromoteSubmit(id){
              //alert('got into Edit Promotions');
              var dataString = "id="+ id;
              alert(dataString);
              function getRandomInt() {
                  return Math.floor(Math.random() * Math.pow(10,6));
              }
              //var url = "SellerPanel/post_repromote.php?"+getRandomInt();
              //alert ("url is: "+ url);
              if(dataString=='')
              {
                  alert('Some Problem Occurred, Please try Again');
              }
              else
              {
              //alert('into post');
              $.ajax({
                  type: "POST",
                  url: "SellerPanel/post_repromote.php?rnd="+getRandomInt();
                  data: dataString,
                  cache: false,
                  success: function(html){
                      //$("#tweet").val('');
                      //$("#preview").hide();
                      $("#RePromoteReplace").replaceWith(html);
                      alert('Product Successfully Loaded!!! Edit(Optional) &amp; Click Promote Button in bottom section')
                  }
                  });
              }return false;
              }
  </code></pre>