apielotje apielotje - 1 month ago 23
Ajax Question

Sketchfab AJAX json call

I'm trying to collect the url for a sketchfab model thumbnail.

view-source:https://api.sketchfab.com/v2/models/b894deeab7904df3a1f6016053604960

When ik go to the above url, I can see the information I need.

Now i'm trying to make an AJAX call so I can dynamicaly use the thumbnail url.



$.ajax({
url: 'https://api.sketchfab.com/v2/models/b894deeab7904df3a1f6016053604960',
type: 'GET',
crossDomain: true,
success: function(data){
alert(data);
}
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>





Somehow, i'm just getting [object Object] back, I don't understand what I am doing wrong. Probably something stupid...

Answer

You are getting back the JSON data in object form - to make it readable you need to stringify it:

alert(JSON.stringify(data))

But you shouldn't really need to do this, other than to make it readable, so just work with what you get back.