cineworld api信息空白

时间:2013-01-09 23:53:43

标签: jquery api

嗨,我很高兴使用API​​,并且在尝试从cineworld api中重新获取信息时遇到问题,任何人都使用过它。

这是他们给出的一个例子,但我似乎无法从中提取任何信息?

<script>
$(document).ready(function() {
$('a.retrieve').click(function() {
    $.ajax({
        url: '/api/quickbook/films',
        type: 'GET',
        data: {key: 'qUnEyRXt', full: true, cinema: 33},
        dataType: 'jsonp', // Setting this data type will add the callback parameter for you
        success: parseFilms
    });
});

$('a.clear').click(function() {
    $('span.film.count').text('0');
    $('ol.film.list').empty();
});
});

 function parseFilms(response, status) {
var html = '';

// Check for errors from the server
if (response.errors) {
    $.each(response.errors, function() {
        html += '<li>' + this + '</li>';
    });
} else {
    $('span.film.count').text(response.films.length);
    $.each(response.films, function() {
        html += '<li>' + this.title + ' (' + this.classification + ')</li>';
    });
}

// Faster than doing a DOM call to append each node
$('ol.film.list').append(html);
}


</script>  

网络文档链接为https://www.cineworld.co.uk/developer/jquery

任何帮助或建议都会很好,非常感谢

1 个答案:

答案 0 :(得分:0)

实际上,它有效!

以下是$.ajax()上传递的网址

http://www.cineworld.co.uk/api/quickbook/films?key=qUnEyRXt&full=true&cinema=33

以下是代码

<html>
  <head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
        $('a.retrieve').click(function() {
          $.ajax({
              url: 'http://www.cineworld.co.uk/api/quickbook/films',
              type: 'GET',
              data: {key: 'qUnEyRXt', full: true, cinema: 33},
              dataType: 'jsonp', // Setting this data type will add the callback parameter for you
              success: parseFilms
          });
        });

        $('a.clear').click(function() {
            $('span.film.count').text('0');
            $('ol.film.list').empty();
        });
      });

      function parseFilms(response, status) {
        var html = '';

        // Check for errors from the server
        if (response.errors) {
            $.each(response.errors, function() {
                html += '<li>Error' + this + '</li>';
            });
        } else {
            $('span.film.count').text(response.films.length);
            $.each(response.films, function() {
                html += '<li>' + this.title + ' (' + this.classification + ')</li>';
            });
        }

        // Faster than doing a DOM call to append each node
        $('ol.film.list').html(html);
      }
    </script>  
  </head>
  <body>
    <a class="retrieve" href="#retrieve">Retrieve</a>
    <a class="clear" href="#clear">Clear</a>
    <span class="film count"></span>
    <ol class="film list">
    </ol>
  </body>
</html>