if i call reload function before ajax call then can ajax execute or not?
function my_status_update(id,va){
$(".close-menu").trigger("click");
var status = va;
var id = id;
$.ajax({
type: "POST",
url : base_url+'home/update_status_job_naha?id='+id+'&&val='+status,
data: {status:status,id:id},
success: function(){
},
});
location.reload();
}
public function update_status_job_naha(){
$status = $_REQUEST['val'];
$id = $_REQUEST['id'];
$data = array(
'shipping-status' => $status,
'shipping_status' => $status,
'status_change_dt' => date('d-m-Y h:i:sa'),
);
$this->db->where('id', $id);
$this->db->update('one_table', $data);
$d_id=$this->session->userdata('user_id');
$status = $_REQUEST['val'];
$id = $_REQUEST['id'];
$data = array(
'tracking_reference' => $id,
'shipping_status' => $status,
'updated_by' => $d_id
);
$this->db->insert('second_table',$data);
if ($status=='Delivered' && isset($_REQUEST['amount'])) {
$ins_am=0;
$amount = $_REQUEST['amount'];
$d_id=$this->session->userdata('user_id');
$amount_d_b = $this->Common_Model->get_wallet_amount_ofdriver($d_id);
$ins_am =($amount_d_b[0]->delv_amount+$amount);
$dataam = array('delv_amount' => $ins_am );
$this->db->where('id', $d_id);
$this->db->update('third_table', $dataam);
}
$url = 'https://this_is_a_api/notify-order-status/';
$ch = curl_init($url);
$payload = array(
'tracking-reference'=>$id, 'shipping-status'=>$status
);
$data = json_encode($payload);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json',
'Media type:: application/json'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return true;
}
here $url = 'https://this_is_a_api/notify-order-status/';
this is very slow.
my issues are:
- i update status with ajax call
- in ajax call have a api link (that link was very slow.when i got the response i become a old man )
what i need:
- api response no matter about me that will update in background
- reload my page with new status
question from:
https://stackoverflow.com/questions/65917469/if-i-call-reload-function-before-ajax-call-then-can-ajax-execute-or-not 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…