我已将数据传递给 ajax 以 curl 但无法解析我在 ajax 中获取的 json 数据调用我的 ajax 代码。
$.ajax({
      url: 'http://localhost/curl_call.php',
         type:"POST",
        data:
    {
        url_path:"http://localhost/login/", 
        data:"name=bddd&password=abc",
    },
    crossDomain: true,
        processData: true,
        success:function(response)
    {
              res_par=JSON.parse(response);
               alert(res_par["success"]);
            }
 )};
curl_call.php:
function curl_load($url,$post_data){
curl_setopt($ch=curl_init(), CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
if((isset($_POST["url_path"]))&&($_POST["url_path"]=="http://localhost/api/login/"))
{
echo json_encode(json_decode(curl_load($_POST["url_path"],$_POST["data"])));
}
为什么无法解析返回数据?