0

I am trying to retrieve a json feed every 1 second. The URL that I am trying to retrieve displays JSON in the browser but will not be retrieved via a jquery getJSON

http://www.ridestreamline.com/Services/JSONPRelay.svc/GetMapVehiclePoints

function getBusLoc() {
$.getJSON('http://www.ridestreamline.com/Services/JSONPRelay.svc/GetMapVehiclePoints?callback=?', function(data) {
    console.log(data);
    setTimeout(getBusLoc, 1000);
})
}
getBusLoc()

It has something to do with the above link. What am I missing? Fiddle here

jotamon
  • 1,532
  • 5
  • 18
  • 38

1 Answers1

1

This is because of same origin policy, you can't sent ajax request from host A to host B, you can use jsonp instead (if your service supports this) , or if you has control to server side and you don't mind to old browsers you can use x-access-control-allow-origin http header in response to OPTIONS request (more info here https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS)

Vlad Nikitin
  • 1,929
  • 15
  • 17