我试图执行一个AJAX请求(文件:AJAX.php),我想在这个AJAX调用期间从AJAX.php触发另一个自定义URL。
我试过CURL,但似乎没有结果。
如果有人能在这方面帮助我,那将是非常有帮助的。
// this function is executed using ajax
private function ajax_process($page){
if($yes){
// execute some code
}else{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://192.168.1.3/test/index.php?fnc=tobasket&aid=378442f7aa427425c741607aa3440ee8&am=1');
curl_exec($ch);
curl_close($ch);
}
// continue the process
}
提前感谢,Arun
试试这个:
// this function is executed using ajax
private function ajax_process($page){
if($yes){
// execute some code
}else{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://192.168.1.3/test/index.php?fnc=tobasket&aid=378442f7aa427425c741607aa3440ee8&am=1');
$headers = array(
'Accept: application/json',
'Content-Type: application/json',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
}
// continue the process
}