JSONP Call from AngularJS Returns 500 Error


#1

I’m trying to do a little AngularJS app with DF as a back-end.

Even with my config allowing ‘*’ for all http methods, I kept getting a cross-domain block request so I switched to trying to do a jsonp call from a factory using the $resource function as follows:

return $resource(‘http://localhost:8090/rest/myappapi/customer?app_name=myapp’,
{callback : ‘JSON_CALLBACK’},
{
query : {method: “JSONP”}
});

(My app is hosted at http://localhost)

The resulting call from the angularjs app is:

http://localhost:8090/rest/myappapi/customer?app_name=myapp&callback=angular.callbacks._0

Which so confuses DF it gives a 500 internal error.

What am I overlooking here?


#2

We adhere to the $http doc on using jsonp, so your call back has to be called JSON_CALLBACK as you’ve tried to do. When using JSONP with angular resource, that call back name changes as you can see in the resulting call. Using $http instead of Angular will get rid of the 500.

HOWEVER
There is a bug with CORS we’re looking at right now with the latest release.
Right now it seems intermittent, more to come on that.


#3

Well I’m just coming up the curve on Angularjs and tutorials I came across kind of recommend $resource over $http.