企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ <title>Document</title> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> </head> <body> <img src="images/movie.webp" alt="" id="img"> <p>评分:<span id="average">8.2</span></p> <form > <input type="text" id="user" name="user"> <input type="button" id="btn" value="搜索"> </form> <script> var user = document.getElementById("user"); var btn = document.getElementById("btn"); var img = document.getElementById("img"); var average = document.getElementById("average"); btn.onclick = function(){ var url ="https://douban.uieee.com/v2/movie/search?q="+user.value+"&count=1"; $.ajax({ url, type:"get", dataType:"jsonp", success:res=>{ /* 渲染数据 */ var averageData = res.subjects[0].rating.average; var imgUrl = res.subjects[0].images.small; img.src=imgUrl; average.innerHTML = averageData; } }) } </script> </body> ~~~