我正在使用codeigniter,然后在执行删除操作后重定向。 这是我要删除的脚本
if ($this->input->post('chkv')) {
$id = $this->uri->segment(4);
$this->md_distributor->deletesite();
redirect('admin/distributor/menulist/2/'.$id);
此控制器中有3个curl,这是我的curl请求
function getROprovince()
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://pro.xxxxx.com/api/province",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"key: xxxxxxx"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
return json_decode($response)->rajaongkir->results;
}
}
第二次卷曲
function getROCity($province)
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://pro.xxxxx.com/api/city?province=".$province,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"key: xxxxx"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
return json_decode($response)->rajaongkir->results;
}
}
第三次卷曲
function getROKec($city)
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://pro.xxxxx.com/api/subdistrict?city=".$city,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"key: xxxxxx"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
//echo $response;
return json_decode($response)->rajaongkir->results;
}
}
如果仅使用location.href =没关系。 因为首先使用location.href加载而没有问题
但是当执行删除操作后,我使用重定向时,仅执行一次curl,并且它是随机的。
请告知。