This is a cross domain call. I use &callback=?
to make it work, the response is JSON. I am using this information to print traffic messages on a google map.
This is working alright, but some times (50% almost) I get an error
500 internal server error
from the server.
Loading the API link in the browser never fails, so what bothers me is that this map is not working on every other refresh.
I have tried a lot of different methods for calling the api, including the AJAX function with jsonp format, but nothing seems to work.
Really annoying that this only happens from time to time.
Is there something I am missing, or is JS not the best option for getting a JSON cross domain?
$.getJSON( "http://sencored.com/api/external/feed?feed=traffic&callback=?", function( data ) {
list = data.events.list;
dispplayOnMap();
});
For those interested; I ended up using PHP for this. Same URL, no errors.
public static function getJSON($url) {
try {
$json_feed = file_get_contents($url);
return $json_feed;
} catch(Exception $e) {
return "error: " . $e;
}
}