First, CORS is tricky, a PITA, so don't feel bad if you are having problems.

JSONP is a good, easy solution for GET ting data. It does not work well for PUT, POST, DELETE Somewhere I've seen some angular examples with JSONP - test if you are receiving data - then in what format the data is in (try showing what the response looks like it console.log or even alert) to see what form the data is coming in - you might have to strip off something or reformat the response in your controller.

One issue with CORS and Angular is if the server requires a "pre-flight" request. In short your app needs to send a notice, then receive a response, then connect. Someone did post some angular code how to do this - try to google it.

sorry, have no experience with using a promise so can't help you with that - try 1 step at a time, get the data, see what you get, then try to add the promise in and track down where the error is.


On 02/19/2014 08:42 PM, telagraphic wrote:
Attempting to make a http call to weather underground api loosely based off of Air Lerner's Angular Chrome App <http://www.ng-newsletter.com/posts/chrome-apps-on-angular.html>.

This is my code <https://gist.github.com/telagraphic/9105662> which contains two calls to the same api call, one using $http with CORS http header configuration and another call using jsonp that receives the json payload but the view won't display it.

I've read that CORS is the preferably approach over JSONP, but I'm a little clueless as to why I'm getting the No 'Access-Control-Allow-Origin' as I've added the proper http header code in my angular config code.

My secondary approach with JSONP will console.log the response object but won't display on my view.

Any assistance that will aid my comprehension of these approaches is greatly appreciated.

I think my local host server doesn't accept the response from weather ground for my http call due to missing the 'Access-Control-Allow-Origin'.

No idea of what do if that is the case...
--
You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to