1

こんにちは、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>  

Web ドキュメントのリンクはhttps://www.cineworld.co.uk/developer/jqueryです

どんな助けやアドバイスも大いに感謝します

4

1 に答える 1

0

実際、それは機能します!

渡す URL は次のとおり$.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>
于 2013-01-10T00:30:47.613 に答える