Javascript 使用jquery提取json数据
使用TMDBAPI使用jquery提取电影信息Javascript 使用jquery提取json数据,javascript,jquery,ajax,json,Javascript,Jquery,Ajax,Json,使用TMDBAPI使用jquery提取电影信息 $(document).ready(function(){ var url = 'http://api.themoviedb.org/3/', mode = 'search/movie?query=', input, movieName, key = '&api_key=fed63cb1875f494391fd712f9a2aed7e'; 单击按钮,它将调用api
$(document).ready(function(){
var url = 'http://api.themoviedb.org/3/',
mode = 'search/movie?query=',
input,
movieName,
key = '&api_key=fed63cb1875f494391fd712f9a2aed7e';
单击按钮,它将调用api
$('#submit-btn').click(function() {
var input = $('#movie-text').val(),
movieName = encodeURI(input);
$.ajax({
type: 'GET',
url: url + mode + input + key,
async: false,
jsonpCallback: 'testing',
crossDomain: true,
contentType: 'application/json',
dataType: 'jsonp',
success: function(json) {
console.dir(json);
},
error: function(e) {
console.log(e.message);
}
});
var newurl = url + mode + input + key ;
console.log(newurl);
//giving errors in get
$.getJSON(newurl+"?callback=?",function(json){
console.log(json[0].results[0].original_title);
//printing the movie title on the ***console***
});
});
});
它给了我以下的错误
获取…9a2aed7e?callback=jQuery19104732654287945479
b、 extend.ajax
b、 extend.getJSON
(匿名函数)
b、 事件调度
v、 处理
加载资源失败:服务器响应状态为401(未授权)
您必须提供有效密钥
无效密钥:
请按如下方式使用api密钥:
fed63cb1875f494391fd712f9a2aed7e
请检查以下url
:
使用有效密钥,代码看起来正常,密钥正常。它在回调中给出错误,可能是