我试图执行一个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
}
提前致谢, 阿伦
答案 0 :(得分:0)
试试这个:
// 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
}