this is my JS code below:
function getTopProductsApi(){
var result;
$.ajax({
url: API_url,
type: "get",
data: ({}),
async:false,
dataType: "jsonp",
jsonpCallback:"success_jsonpCallback",
success: function(rs){
result = rs;
}
});
return result ;
}
var result = getTopProductsApi();
alert(result);
PHP
public function test(){
echo $_GET['callback']. '(' . json_encode('213213') . ')';
}
I am sure that I get the return json data: The json data I get below:
success_jsonpCallback("213213")
But there have no data when I alert.
Can someone tell the reason? Thanks