2
我在使用jsonp数据类型时没有从ajax获取json响应/成功。但我正在逐渐空白response.Is是GAPI的我得到这个问题或任何other.I发现类似的问题 Not able to get the json responseAjax json在POST方法中未成功响应
,这是我的jQuery代码
$.ajax({ url: 'includes/gapi.apis.php',
data: {action: 'keyword'},
type: 'post',
async:false,
dataType: "jsonp",
success: function(obj) {
alert(obj);
}
PHP代码
$ga->requestReportData(ga_profile_id,array('keyword'),array('visits','pageviews'),array('-visits'),$filter,$startDate, $endDate, $startIndex, $maxResults);
foreach($ga->getResults() as $result)
{
//echo $result->getKeyword()."-------------------".$result->getVisits()."<br>";
$data[$i]['keyword']=$result->getKeyword();
$data[$i]['visits']=$result->getVisits();
$data[$i]['pages_visits']=round(($result->getPageviews())/$result->getVisits(),2);
$i++;
}echo json_encode($data);