weixin_33713707 2017-04-17 12:33 采纳率: 0%
浏览 30

Ajax查询以获取json数据

I am trying to fetch title from one api, but getting some error. This is my 3rd time using ajax. Please let me know where I am doing wrong.

Here is My code.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Search Movies</title>
    <style type="text/css">
        #movieTemplateContainer div
        {
            width:500px;
            padding: 10px;
            margin: 10px;
            border: black solid 1px;
        }

    </style>
</head>
<body>
<label>Search Movies:</label>
<input id="movieName" size="50" />
<button id="btnLookup">Lookup</button>

<div id="movieTemplateContainer"></div>

  <script id="movieTemplate" type="text/x-jquery-tmpl">
<div>      
         <img src="${BoxArt.LargeUrl}" />
        <strong>${Name}</strong>
        </br>
        <button id="playButton" movieID=${NetflixApiId} onclick="play(this)">Play Now</button>
        <p>
        {{html Synopsis}}
        </p>
  </div>  
</script>

  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="jquery.tmpl.js"></script>
    <script type="text/javascript">

    $("#btnLookup").click(function () {

        // Build OData query
        var movieName = $("#movieName").val();
        var query = "http://netflixroulette.net/api/api.php?" // netflix base url
        + "title=" + escape(movieName) // top-level resour

        // Make JSONP call to Netflix
     $.ajax({
            dataType: "jsonp",
            url: query,
            jsonpCallback: "callback",
            success: callback
            });
        });

    function callback(result) {
        // unwrap result
        var movies = result.d.results;

        $("#movieTemplateContainer").empty();
        $("#movieTemplate").tmpl(movies).appendTo("#movieTemplateContainer");
    }

    </script>


<script src="http://jsapi.netflix.com/us/api/js/api.js"></script>


</body>
</html>

I am using this API

Please let me know how I can fix the error.

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题