Itunes 搜索 Api 上的未定义值
我有这个 HTML 和 Js,第一个结果是一个未定义的值。 我想删除那个未定义的值。
我知道这是一个简单的解决方案,但我无法弄清楚。 我请求帮助.. 谢谢。
自定义。 js
$(function(){
$.ajax({
url: "--URL--",
dataType: 'jsonp',
success: function(json_results){
console.log(json_results);
$('#twitList').append('<ul data-role="listview"></ul>');
listItems = $('#twitList').find('ul');
$.each(json_results.results, function(key) {
html = '<img src="'+json_results.results[key].artworkUrl60+'"/>';
html += '<h3><a href="#">'+json_results.results[key].collectionName+'</a></h3>';
html += '<p>From: '+json_results.results[key].artistName+'</p>';
html += '<p>Created: '+json_results.results[key].releaseDate+'</p>';
listItems.append('<li>'+html+'</li>');
});
// Need to refresh list after AJAX call
$('#twitList ul').listview();
}
});
})
HTML
<title>Itunes</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script src="custom.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Itunes</h1>
</div><!-- /header -->
<div data-role="content">
<div id="twitList"></div>
</div><!-- /content -->
</div><!-- /page -->
</body>
I have this HTML and Js and the firtst result is an undefined value.
I want to remove that undefined Value.
I know its a simple solution but i cant fugure it out.
I ask for help please..
Thank you.
Custom. js
$(function(){
$.ajax({
url: "--URL--",
dataType: 'jsonp',
success: function(json_results){
console.log(json_results);
$('#twitList').append('<ul data-role="listview"></ul>');
listItems = $('#twitList').find('ul');
$.each(json_results.results, function(key) {
html = '<img src="'+json_results.results[key].artworkUrl60+'"/>';
html += '<h3><a href="#">'+json_results.results[key].collectionName+'</a></h3>';
html += '<p>From: '+json_results.results[key].artistName+'</p>';
html += '<p>Created: '+json_results.results[key].releaseDate+'</p>';
listItems.append('<li>'+html+'</li>');
});
// Need to refresh list after AJAX call
$('#twitList ul').listview();
}
});
})
HTML
<title>Itunes</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script src="custom.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Itunes</h1>
</div><!-- /header -->
<div data-role="content">
<div id="twitList"></div>
</div><!-- /content -->
</div><!-- /page -->
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:
})
EDIT:
})
我通过将 *.phobos.apple.com 列入白名单来运行此程序(修复第一行中的未定义值)。并使用您的确切代码。
I got this running (fixes undefined value on the first line) by whitelisiting *.phobos.apple.com. and using your exact code.