我想在浏览器中使用JavaScript输出Json数据,但我只能在console.log中输出,我不知道要搜索什么。我是一个JavaScript的初学者,请帮我在这里。如何在浏览器中打印json console.log数据?
的script.js
$(document).ready(function() {
var url = 'http://api.themoviedb.org/3/',
mode = 'movie/',
movie_id,
key = '?api_key=e9dfeccf734a61b9a52d9d7660f0d0a1';
$('button').click(function() {
var input = $('#movie').val(),
movie_id = encodeURI(input);
$.ajax({
type: 'GET',
url: url + mode + movie_id + key,
async: false,
jsonpCallback: 'testing',
contentType: 'application/json',
dataType: 'jsonp',
success: function(json) {
console.dir(json);
},
error: function(e) {
console.log(e.message);
}
});
});
});
的index.php
<input id="movie" type="text" /><button>Search</button>
此代码输出的console.log所有的数据,但我想要做的就是它应该在浏览器中显示的数据,我想输出一些像电影标题,概述和图像等特定对象。
为你分享JSON。 –
[在HTML表格中显示JSON数据]的可能重复(https://stackoverflow.com/questions/19901843/display-json-data-in-html-table) –
@HassanImam https://jsfiddle.net/b46xhn3f/ 8 /搜索并检查控制台。 –