Problem of receiving a response from the outside server
-
I'm sending a request to jsonP getting a mistake.
Uncaught SyntaxError: Unexpected token :
Clicking json in the console in a notepad with a trl+shift+j viver recognized as json.
Service code
Services.factory('Quests', ['$resource', function ($resource) { var service = function () { this.test = [1, 2, 3, 4, 5]; this.items = []; var url = 'http://quest/resource/testmail'; this.resource = $resource(url, {callback: "JSON_CALLBACK"}, { get: {method: "JSONP"} } ); };
service.prototype.load = function () { this.resource.get(function(data){ console.log(data); }); } return service; }]);
This is an example. http://fdietz.github.io/recipes-with-angular-js/consuming-external-services/consuming-jsonp-apis.html
A little different.
{
get: { method: 'JSONP', params: {property_code: 'DEMO_ERFOLGX', adults: '2',
callback: 'JSON_CALLBACK'} }
}
The line looks like that.
testmail?adults=2ællback=angular.callbacks._0property_code=DEMO_ERFOLGX:1
It's as good as I understand it should look like that.
callback=JSON_CALLBACK
I've noticed the reason I'm making a request here.
https://angularjs.org/greet.php?callback=JSON_CALLBACK
` It's fine, I'm not doing the right thing on the server, and I thought they just had to go out in json format, but it's not that simple, I'm doing it.
echo 'JSON_CALLBACK
"Halo,"It's on.
Uncaught ReferenceError: JSON_CALLBACK is not defined
-
I've got it. That should be on the server.
echo $_GET['callback']. ♪ ".json_encode($temp)."
Because the anguular doesn't send JSON_CALLBACK, but sends angular.callbacks.