The Movie Database 支持

There is a great example that I used successfully with your old database a few years ago. https://www.smashingmagazine.com/2012/02/beginners-guide-jquery-based-json-api-clients/ This doesn't work with the current db, can you please send a link to working examples. My jquery is rusty and I've been trying to figure out which } or ) or ; I'm missing for the past hour. If I come up with a working one before you answer I'll post it.

7 回复(第 1 页,共 1 页)

Jump to last post

Here's a working jQuery example that uses search. Make sure to change line 11 with your API key.

That was quick! Thanks for the fast reply! No, unfortunately I mean I need a lot more, as in something with a working input box. I took your code and inserted my api and did in fact get results for the fight club options. Now I'd like to be able to get an input box that will output any movie results, not just fight club. The really great working example above had a way to get a poster. I'm trying to combine both you and the other example. Here is what I have that doesn't work at all.: (by the way it is ok if you just say, "no, I don't code for free", like I said I'll eventually figure this out and post my own example) Thank you!!

<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>jQuery Test</title>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>




  <h2>jQuery Test</h2>
  <h3>Results</h3>

  <p id="error"></p>
  <ul id="search_results"></ul>
     <div id="fetch">
      <input type="text" placeholder="Enter a movie title" id="term" />
      <button id="search">Find me a poster</button>
   </div>
   <div id="poster"></div>


  <script type="text/javascript" charset="utf-8">
    var api_key = 'mysecretapikey';
  $(document).ready(function(){
      $.ajax({
        url: 'http://api.themoviedb.org/3/search/movie?api_key=' + api_key + '&query=',
        dataType: 'jsonp',
        jsonpCallback: 'testing'
      }).error(function() {
        console.log('error')
      }).done(function(response) {
       if (response.total_results > 0) 
        {
        content = "";
            for (i = 0; i < response.total_results; i++) 
            {
            url = response.results[i].poster_path;
            content += "";
            };
        $("#poster").html(content);
            }
      });

    });
        </script>
</body>
</html>
$(document).ready(function(){
      $.ajax({
        url: 'http://api.themoviedb.org/3/search/movie?api_key=' + api_key + '&query=',
        dataType: 'jsonp',
        jsonpCallback: 'testing'
      }).error(function() {
        console.log('error')
      }).done(function(response) {
       if (response.total_results > 0) 
        {
        content = "";
            for (i = 0; i < response.total_results; i++) 
            {
            url = response.results[i].poster_path;
            content += "";
            };
        $("#poster").html(content);
            }
      });

    });

Hi there,

If you have more specific implementation questions, I would suggest asking your question on something like Stack Overflow.

Cheers.

There used to be working examples on the site - are the located somewhere else or are they just removed?

found a working example! http://anthonybrown.github.io/movie-poster/

pure brilliant genius. Just have to change two things to get it working: var api key: "your api key here"; var baseimg = "http://image.tmdb.org/t/p/w185//";

Happy to hear you figured it out.

找不到电影或节目?登录并创建它吧。

全站通用

s 聚焦到搜索栏
p 打开个人资料菜单
esc 关闭打开的窗口
? 打开键盘快捷键窗口

在媒体页面

b 返回(或返回上级)
e 进入编辑页面

在电视季页面

(右箭头)下一季
(左箭头)前一季

在电视集页面

(右箭头)下一集
(左箭头)上一集

在所有图像页面

a 打开添加图片窗口

在所有编辑页面

t 打开翻译选择器
ctrl+ s 提交

在讨论页面

n 创建新讨论
w 切换关注状态
p 设为公开 / 私密讨论
c 关闭 / 开放讨论
a 打开活动页
r 回复讨论
l 跳转至最新回复
ctrl+ enter 发送信息
(右箭头)下一页
(左箭头)前一页

设置

想给这个条目评分或将其添加到片单中?

登录

还不是会员?

注册加入社区