Im currently trying to use the OSRS api in jquery.
I have used it prior to this with httparty in rails but wanted to see if i could do it in a javascript way.
However i seem to be having a problem parsing the contence of the response despite it appearing valid.
My code can be seen below:
// jquery Stuff
$( document ).ready(function() {
var url_test = "http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=207&format=json";
$.ajax({
crossDomain: true,
dataType: "jsonp",
url: url_test ,
}).done(function ( data ) {
console.log(data);
alert( "Load was performed." );
});
});
This is the 'broken' responce i get from the api which throws the error of Uncaught SyntaxError: Unexpected token :
{"item":{"icon":"http://services.runescape.com/m=itemdb_oldschool/1492081307848_obj_sprite.gif?id=207","icon_large":"http://services.runescape.com/m=itemdb_oldschool/1492081307848_obj_big.gif?id=207","id":207,"type":"Default","typeIcon":"http://www.runescape.com/img/categories/Default","name":"Grimy ranarr weed","description":"It needs cleaning.","current":{"trend":"neutral","price":"7,338"},"today":{"trend":"negative","price":"- 20"},"members":"true","day30":{"trend":"positive","change":"+2.0%"},"day90":{"trend":"positive","change":"+8.0%"},"day180":{"trend":"positive","change":"+8.0%"}}}
Is there someway that i can load this data correctly. I think its because of using jsonp if i where to guess. However i cant seem to load the api threw json data type as it throws a CORS error. So im a little stuck and any help with this would be great thanks !