javascript - Returns undefined when attempting to run JQuery -
$.getjson('http://robloxplus.com:2052/inventory?username=itracking', function(data){ $.each(data, function(item){ console.log(item['id']) }); });`
returns undefined when attempting run on external website. supposed output each id of every item in list (http://robloxplus.com:2052/inventory?username=itracking)
how fix this?
edits>
i want iterate on each individual id, each of these numbers "168167114": , "135470963": etc. etc. , fetch data follows (i.e. name:"", totalserial:"")
is request being made on same domain robloxplus.com ?
i'm new this.. don't understand javascript and/or jquery. @pedro lobito no, it's not. –
explanation:
http requests javascript traditionally bound same origin policy, means ajax requests must have same domain , port. common ways around json-p, proxying , message passing via s. these have quirks, thing have in common legacy browser support.
solution
1 - if robloxplus.com yours, can enable cors
2 - if not, can use yql (yahoo! query language) bypass cors
when 1 of above options fulfilled, can make json request, i.e.:
$.ajax({ url: 'http://robloxplus.com:2052/inventory?username=itracking', type: 'get', datatype: 'json', success: function(data) { $.each(data.id, function(item) { console.log(item); }); }, error: function(e) { console.log(e.message); } });
Comments
Post a Comment