我有以下js腳本和html代碼,並希望在頁面上輸出結果。當我在控制檯上運行它時,我可以看到如下結果:顯示json結果頁
[對象{title =「他們沒有鞠躬;他們沒有焚燒」,link =「http://xxxxxxx.com/bow -burn /「,author =」Admin「,more ...},Object {title =」當你最後一次感覺到......你生活中的螞蟻區域時,「link =」http://xxxxxxx.s.sificificant -areas-life /「,author =」Admin「,more ...},Object {title =」婚姻在所有...中榮幸「,link =」http://xxxxxxx...arriage-honourable-all/「 ,筆者= 「管理」,更...},{對象標題= 「住在堡壘之神」,鏈接=「HTTP://xxxxxxx...elling-strongholds-
的html代碼:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="css/style.css"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<div id="blog" data-role="page">
<div data-role="header" class="sys_hd" data-position="fixed" data-id="sys_header" >
<h1>Sysads Posts</h1>
</div><!-- header -->
<div data-theme="c" data-role="content" id="postlist"> </div><!-- content -->
<div data-role="footer" data-position="fixed" data-id="sys_footer" >
<div data-role="navbar" >
<ul>
<li><a href="#blog" class="sys_ft">Home</a></li>
<li><a href="#blog" class="sys_ft">Disclaimer</a></li>
</ul>
</div><!-- navbar -->
</div><!-- footer -->
</div><!-- page -->
</body>
</html>
個
js代碼:
$(document).ready((function(){
url = 'http://xxxxxxxx.com/category/daily-devotion/feed/';
$.ajax({
type: "GET",
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q=' + encodeURIComponent(url),
dataType: 'json',
error: function(){
alert('Unable to load feed, Incorrect path or invalid feed');
},
success: function(xml){
postlist = xml.responseData.feed.entries;
console.log(postlist);
}
});
}));
JSON解析器說:「JSON表達必須是一個對象或數組 –
有了這個答案,我暗示,即在正在添加JSON數據不正確,我們來看一看你是串行器。使用 –