0

I am trying to hook up to a very basic API to see what sort of results I may get back, but I am getting the above error.

I have searched and I cannot see where my code might be going wrong.

Here is my basic code:

$.ajax({
        type: 'GET',
        dataType: 'jsonp',
        url: 'https://boardgameprices.co.uk/api/search?sitename=local&search=kingdomino',
        cache: false,
        crossDomain: true,
        success: function (data) {
            alert("worked");
        },
        error: function (jqxhr) {
            alert(jqxhr.responseText);
        }
    });

I am getting a response body back from the API:

{"items":[{"id":19200,"name":"Kingdomino","version":"","bestprice":15.5,"bestprice_ccy":"GBP"},{"id":21960,"name":"Kingdomino XXL","version":"","bestprice":52.78,"bestprice_ccy":"GBP"}],"count":"2","pages":1,"per_page":20}

And the ajax call is bringing a 200 response back as well.

Can anyone see what might be causing this issue?

Cœur
  • 37,241
  • 25
  • 195
  • 267
kingtreelo
  • 251
  • 3
  • 15
  • 3
    The response is JSON, not JSONP. You need to use `dataType: 'json'` instead. ***However*** you'll then get this error: `No 'Access-Control-Allow-Origin' header is present on the requested resource` as the domain you're calling does not include CORS headers in the response. All this means that you will not be able to call that domain directly using JS code due to the Same Origin Policy – Rory McCrossan Oct 02 '17 at 12:08
  • @RoryMcCrossan: Well, they *may* be able to, if boardgameprices.co.uk treats their origin differently... But yeah, unlikely. :-) – T.J. Crowder Oct 02 '17 at 12:10

0 Answers0