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);