Ajax POST请求无效

时间:2014-04-24 14:57:01

标签: php jquery ajax

我想在此页面上获取BlackBerry PIN:http://m.tokobagus.com/iklan/drees-import-51336153.html/?&opt=2&int=1&pg=1&catid=230&subcatid=230

它向此URL发送Ajax POST请求:http://m.tokobagus.com/search/ajaxbb

他们的剧本是:

$.post(url,{pin:$("#advscrw").val()},function(k){k=$.parseJSON(k)});

成功结果:{"状态":1,"数据":" xxxxxxx"}

pin是唯一的参数,其值为N0Q2MzY2MUQ=。但是在使用PHP测试请求时,结果是{" status":0," data":null}

    $options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data),
    ),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

var_dump($result);

出了什么问题?

1 个答案:

答案 0 :(得分:0)

如果它看到X-Requested-With: XMLHttpRequest请求标题,它只响应实际数据。

'header'  => "Content-type: application/x-www-form-urlencoded\r\n" .
             "X-Requested-With: XMLHttpRequest\r\n",
相关问题