Issue with JSON & Ajax request

Issue with JSON & Ajax request

Hi!

I try to get some data from one of those APIs out there..
What I can see in the documentation, this should be written something like the code below.
I got the data back in Postman, using the URL (with my own api Key), but in google chrome I just 'error ' got Unexpected token : and {"StatusCode":0," - btw, not sure what I should place in the headers..?

Any one that could guide me here?


Thanks in advance!

  1. $(function(){
  2.     $.ajax({
  3.         async: true,
  4.         dataType: 'json',
  5.         crossDomain: true,
  6.         url: "https://api.sl.se/api2/realtimedeparturesV4.json?key=xxxxx&siteid=9192&timewindow=60?callback=?",
  7.         method: "GET",
  8.         headers: {
  9.             "Accept": "application/jsonp;odata=verbose", 
  10.         },
  11.     })

  12.     .done(successFunction)
  13.     .fail(failFunction)

  14.     function successFunction(data){
  15.         console.log('ok..')
  16.     }
  17.     function failFunction(request, textStatus, errorThrown) {
  18.         console.log('not ok.. ');
  19.     }
  20. });