Try:
app.service("dangerousAPI", function($q) {
this.get = get;
function get(funcName, url) {
var dataDefer = $q.defer();
window[funcName] = function(x) {
dataDefer.resolve(x);
}
var tag = document.createElement("script");
tag.src = url;
document.getElementsByTagName("head")[0].appendChild(tag);
return dataDefer.promise;
}
})
dangerousAPI.get('process',url).then(function(data) {
$scope.myData= data;
console.log(data);
})
For more information, see Not a Legal JSONP API
when I put {{myData}}
, I have complet jsonp,
I am glad you were able to get the data with this answer. It shows that the server is not returning legal JSON. The server should be fixed to return either legal JSON or legal JSONP.
To make the server respond with a valid JSONP array, wrap the JSON in brackets () and prepend the callback:
echo $_GET['callback']."([{'fullname' : 'Jeff Hansen'}])";
Using json_encode() will convert a native PHP array into JSON:
$array = array(
'fullname' => 'Jeff Hansen',
'address' => 'somewhere no.3'
);
echo $_GET['callback']."(".json_encode($array).")";
For more information, see Simple PHP and JSONP example