Ajax Mysql PHP How to show $_SESSION arrays result into DIV
<p>My friends,</p>

<p>I´m facing some hard trouble with Ajax &amp; PHP integration. I have a simple code as below that returns the data from database and shows into div class="item-list". When the user puts the quantity and clicks on submit button, the selected item is uploaded into div class="returned", like the "add item to cart" function. The code is working as well (add &amp; remove from list), but only with refresh on page. 
I saw many examples on web and I tried to adapt them to my code (today is my third day of fighting), but with no success. Could you please show to me a way to load the selected items into div class="returned" without refresh on page?        </p>

<p>Best regards &amp; thanks a lot!</p>

<pre><code>  &lt;?php
session_start();

   if(isset($_POST["add_to_table"])){
   if(isset($_SESSION["dynamic_list"])){    

    $item_array_id = array_column($_SESSION["dynamic_list"], "item_id");
    if(!in_array($_GET["idproduct"], $item_array_id)){
    $count = count($_SESSION["dynamic_list"]);
    $item_array = array(
                'item_id' =&gt; $_GET["idproduct"],
                'model' =&gt; $_POST["got_model"],
                'price' =&gt; $_POST["got_price"],
                'item_quantity' =&gt; $_POST["quantity"]
                );
        $_SESSION["dynamic_list"][$count] = $item_array;         
}else{
    echo'&lt;script&gt;alert("Item added!")&lt;/script&gt;';
    echo'&lt;script&gt;window.location="intransit.php"&lt;/script&gt;';
    }
 }else{
   $item_array = array(
                'item_id' =&gt; $_GET["idproduct"],
                'model' =&gt; $_POST["got_model"],
                'price' =&gt; $_POST["got_price"],
                'item_quantity' =&gt; $_POST["quantity"]
                 );
                 $_SESSION["dynamic_list"][0] = $item_array;
    }
   }

    if(isset($_GET["action"])){
    if($_GET["action"] == "delete"){
    foreach($_SESSION["dynamic_list"] as $list =&gt; $values){
    if($values["item_id"] == $_GET["idproduct"]){  
       unset($_SESSION["dynamic_list"][$list]);
       echo'&lt;script&gt;alert("Item removed!")&lt;/script&gt;'; 
       echo'&lt;script&gt;window.location="intransit.php"&lt;/script&gt;'; 
        }
      }
   }
}
?&gt;

 &lt;?php include"header.php" ?&gt;
 &lt;div id="main_box"&gt;
&lt;div id="moviment"&gt;
&lt;div class="item_list"&gt;
&lt;?php
  $query = "SELECT * FROM products ORDER BY model ASC LIMIT 3";
  $result = mysqli_query($connect, $query);
  if(mysqli_num_rows($result) &gt; 0){

     while($row = mysqli_fetch_array($result)){
 ?&gt;
&lt;div id="product_table"&gt;
&lt;form method="post" action="intransit.php?action=add&amp;idproduct=&lt;?php echo $row["idproduct"]; ?&gt;"&gt;
&lt;span&gt;&lt;img src="images/&lt;?php echo $row["image"]; ?&gt;" alt="motor" width="80" height="80" /&gt;&lt;/span&gt;
&lt;span&gt;Model:&amp;nbsp&lt;?php echo $row["model"]; ?&gt;&lt;/span&gt;
&lt;span&gt;Price:&amp;nbsp&lt;?php echo $row["unitprice"]; ?&gt;&lt;/span&gt;
&lt;input type="text" name="quantity" value="1" class="qty" /&gt;
&lt;input type="hidden" name="got_model" value="&lt;?php echo $row["model"]; ?&gt;"  /&gt; 
&lt;input type="hidden" name="got_price" value="&lt;?php echo $row["unitprice"]; ?&gt;"  /&gt;
&lt;input type="submit" name="add_to_table" value="Add Item" /&gt;
&lt;/form&gt;
&lt;/div&gt;&lt;!--end "product_table"--&gt;
&lt;?php       
    }
  }
   ?&gt;
    &lt;/div&gt;&lt;!--end "item_list"--&gt;
    &lt;div class="returned"&gt;
     &lt;table&gt;
    &lt;tr&gt;
    &lt;th&gt;Model&lt;/th&gt;
    &lt;th&gt;Qty&lt;/th&gt;
    &lt;th&gt;Price&lt;/th&gt;
    &lt;th&gt;Total&lt;/th&gt;
    &lt;th&gt;Action&lt;/th&gt;
   &lt;/tr&gt;
    &lt;?php
   if(!empty($_SESSION["dynamic_list"])){
   $total = 0;
   foreach($_SESSION["dynamic_list"] as $list =&gt; $values){  
?&gt;  
    &lt;tr&gt;
    &lt;td&gt;&lt;?php echo $values["model"]; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $values["item_quantity"]; ?&gt;&lt;/td&gt;
    &lt;td&gt;$&lt;?php echo $values["price"]; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo number_format($values["item_quantity"] * $values["price"], 2); ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;a href="intansit.php?action=delete&amp;idproduct=&lt;?php echo $values["item_id"]; ?&gt;"&gt;Remove&lt;/a&gt;&lt;/td&gt;


&lt;/tr&gt;
 &lt;?php
    $total = $total + ($values["item_quantity"] * $values["price"]);
  }
  ?&gt;
  &lt;tr&gt;
  &lt;td colspan="3" align="right"&gt;Total&lt;/td&gt;
  &lt;td align="right"&gt;$ &lt;?php echo number_format($total, 2);?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;

  &lt;?php
}
?&gt;
 &lt;/table&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;?php include"footer.php" ?&gt;
</code></pre>