I was trying to use $http.get
. The page only works if the url I give is a local 'vehicles.json
' But when I give a url, it spits out a blank page. Could someone please help me understand my error?
Asked
Active
Viewed 266 times
2
-
2Open console and fix errors. Then use jsonp method of $http. – dfsq Aug 12 '15 at 06:28
-
looks like CORS issue – Pankaj Parkar Aug 12 '15 at 06:33
-
@dfsq The url to the server doesn't have a jsonp callback. Should I still try to use jsonp method instead of $http? – Aug 12 '15 at 14:41
-
@MartinScore you could go for jsonp request – Pankaj Parkar Aug 12 '15 at 14:55
-
Why are you then use `&format=jsonp`? Anyway this is what you need to do: `If (API supports JSONP?) { use JSONP } else if (CORS supported?) { use GET JSON(API url) } else { create server side proxy and GET JSON(proxy url) }`. – dfsq Aug 12 '15 at 15:03
1 Answers
1
You have to replace this line:
$scope.vehicle = data.['get_vehicles'];
for this:
$scope.vehicle = data['get_vehicles'];
If you modify this in your Plunker, will work.
I hope this solves your question.

borferpa
- 86
- 3
-
Did you check if the proglem is CORS? to check it you can open the console (F12 in Chrome) and look at if appear some message saying something like "XMLHttpRequest cannot load http://domain.example. Origin http://domain.example is not allowed by Access-Control-Allow-Origin." If your problem is this, you can transform your chrome with disable security (http://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome) – borferpa Aug 13 '15 at 06:24