开发者

HUKD API - getJSON Rest call

I'm new to JSON and APIs (everything like that).

I am trying to test out the API over at Hot UK Deals (http://www.hotukdeals.com/rest-api), for a future development.

I have an API key and would like to retrieve data from the hot vouchers.

http://api.hotukdeals.com/rest_api/v2/?key=xxxxxxxxxxx&order=hot&forum=vouchers&results_per_page=5

Now I want to just select one and display it. I can't even do that, I'm not sure if it's something that I'm doing wrong or what.

Now here's my JS code:

$.getJSON('http://api.hotukdeals.com/rest_api/v2/?key=xxxxxxxxx&order=hot&forum=vouchers&results_per_page=5&output=开发者_Go百科json',function(hot){  

    $('div#data').html(hot.title)



        });//end JSON

Now before someone says, that I haven't tried; I have! I have tried different ways to get the title of a deal. But I can't get any output.


The API only supports JSON ans XML, not JSONP. This means that you cannot use javascript in order to consume it due to the same origin policy restriction. Browsers forbid from sending AJAX to different domains. Basically there are two workarounds for this restriction:

  1. JSONP (which unfortunately requires the server to support it, which doesn't seem to be the case for the API you are trying to consume)
  2. Use a server side script on your domain that will act as a bridge and send the AJAX request to your script.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜