title: Show status before refresh the page
body: <p>When i select <strong>checkbox</strong> and click on &quot;<strong>Show Status</strong>&quot; button , its displaying <strong>Status</strong> value only after i refresh the page, but i need to show <strong>before refresh</strong> the page.</p>
  <p><a href="https://i.stack.imgur.com/OzFa0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OzFa0.png" alt="enter image description here" /></a></p>
  <p><strong>html</strong></p>
  <pre class="lang-html prettyprint-override"><code>&lt;td&gt;
    &lt;input type=&quot;checkbox&quot; id=&quot;assigneeid-&lt;?php echo $orderrecords[$k][&quot; tracking_id &quot;]; ?&gt;&quot; onclick=&quot;assignorderids('&lt;?php echo $orderrecords[$k][&quot; tracking_id &quot;]; ?&gt;')&quot; name=&quot;checkassigneeid&quot; class=&quot;assigneeid-order&quot; value=&quot;&lt;?php echo $orderrecords[$k][&quot;
      tracking_id &quot;]; ?&gt;&quot;&gt;
  &lt;/td&gt;
  </code></pre>
  <p><strong>javascript</strong></p>
  <pre class="lang-js prettyprint-override"><code>$('#show_status').click(function() {
    var selected = [];
    $('.assigneeid-order:checked').each(function() {
      selected.push($(this).val());
      $('.assigneeid-order').prop('checked', false);
    });
  
    var jsonString = JSON.stringify(selected);
  
    $.ajax({
      type: &quot;POST&quot;,
      url: &quot;api.php&quot;,
      data: {
        data: jsonString
      },
      success: function(response) {
        response = $.parseJSON(response);
        $.each(response, function(index, val) {
          $(&quot;#&quot; + index + &quot;&quot;).html(val);
        });
      }
    });
  });
  </code></pre>
  <p><strong>api.php</strong></p>
  <pre class="lang-php prettyprint-override"><code>$data = json_decode(stripslashes($_POST['data']));
  $response = array();
  
  foreach($data as $id) {
    $orderid = $id;
    $hide = '';
    $post_data['username'] = 'admin';
    $post_data['password'] = 'admin123';
    $post_data['awb'] = $orderid;
    $url = 'https://plapi.ecomexpress.in/track_me/api/mawbd/';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, &quot;http://plapi.ecomexpress.in/track_me/api/mawbd/&quot;);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FAILONERROR, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
    $output = curl_exec($ch);
    curl_close($ch);
  
    $orderResults = $xml = simplexml_load_string($output);
  
    foreach($orderResults - &gt; object as $child) {
      $status = (string) $child - &gt; field[10];
      break;
    }
    $res = explode(&quot;\n&quot;, $output);
  
    if (!isset($res[13])) {
      $res[13] = null;
    }
  
    $statusfinal = str_replace('&lt;field type=&quot;CharField&quot; name=&quot;status&quot;&gt;', '', $status);
    if ($statusfinal != '') {
      $sqlecom = &quot;UPDATE do_order set in_transit='&quot;.$status.
      &quot;',tconformed_by='Ecom' where tracking_id=&quot;.$orderid;
      $db_handleecom = new DBController();
      $resultecom = $db_handleecom - &gt; executeUpdate($sqlecom);
    }
  
    // store the responce in array 
    $response[$orderid] = $status;
  }
  echo json_encode($response);
  </code></pre>
  <p>Please help me to find solution, i am using mysqli....</p>
  <p>Please let me know if you have any doubts.... Thanks in Advance.</p>
  <p><strong>Update</strong></p>
  <p>Before i was getting status values based on orderid instead of awb , you can see in above image  , that time status was showing before refreshing page. here is code for getting status based on Order ID....</p>
  <pre><code>$curl_data['username']='admin'; 
  $curl_data['password']='admin123'; 
  
  
  $data = json_decode(stripslashes($_POST['data'])); 
  $response = array(); 
  
  foreach($data as $id){ 
  
  $orderid = $id; 
  $curl_data['awb']=$orderid; 
  
  $hide = '';
   $url = 'https://plapi.ecomexpress.in/track_me/api/mawbd/?awb=awbnumber&amp;order='.$orderid.'&amp;username=admin&amp;password=admin123'; 
  $ch = curl_init(); 
  $ch = curl_init(); 
  curl_setopt($ch, CURLOPT_URL,$url); 
  curl_setopt($ch, CURLOPT_POST, true); 
  curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_data); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
  
  
  $output = curl_exec ($ch); 
  curl_close($ch); 
  $res = explode(&quot;\n&quot;,$output); 
  
  if ( ! isset($res[13])) 
  { 
  $res[13] = null; 
  } 
  
  
  
  $status = str_replace('&lt;/field&gt;','',$res[13]); 
  
  
  
  $statusfinal = str_replace('&lt;field type=&quot;CharField&quot; name=&quot;status&quot;&gt;','',$status); 
  if($statusfinal!='') 
  { 
  $sqlecom = &quot;UPDATE do_order set in_transit='&quot;.$statusfinal.&quot;',tconformed_by='Ecom' where order_id=&quot;.$orderid; 
  $db_handleecom = new DBController(); 
  $resultecom = $db_handleecom-&gt;executeUpdate($sqlecom); 
  } 
  
  // store the responce in array 
  
  
  $response[$orderid] = $statusfinal; 
  
  }
  echo json_encode($response);
  </code></pre>
  <p><strong>Update 2</strong></p>
  <p>below <strong>network</strong> tab , i got response properly as <a href="https://pastebin.com/VpWsngnV" rel="nofollow noreferrer">https://pastebin.com/VpWsngnV</a></p>