jquery - Ajax json respond not getting in success in POST method -
i not getting json response/success ajax while using jsonp datatype. getting blank response.is of gapi getting issue or other.i find similar problem not able json response
this jquery code
$.ajax({ url: 'includes/gapi.apis.php', data: {action: 'keyword'}, type: 'post', async:false, datatype: "jsonp", success: function(obj) { alert(obj); }
php code
$ga->requestreportdata(ga_profile_id,array('keyword'),array('visits','pageviews'),array('-visits'),$filter,$startdate, $enddate, $startindex, $maxresults); foreach($ga->getresults() $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);
try this.
$.ajax({ type: 'post', url: "your url", data: "{}", contenttype: "application/json; charset=utf-8", datatype : "json" success : function (response) { alert(response.d); }, error : function (response) { alert(response.d); } })
and , make sure code behind function wbmethod.
Comments
Post a Comment