1
jsonデータの内部要素を取得できません。 Here's jsonデータのリンク。ここでURLからjsonデータを取得する方法は?
は私のコードです:注意すべき
$(document).ready(function() {
//after button is clicked we download the data
$('.button').click(function(){
//start ajax request
$.ajax({
url: "http://www.miamia.co.in/dummy/?json=get_recent_posts",
//force to handle it as text
dataType: "text",
success: function(data) {
//data downloaded so we call parseJSON function
//and pass downloaded data
var json = $.parseJSON(data);
//now json variable contains data in json format
//let's display a few items
$('#results').html('Pages:'+ json.pages + '<br />postid: '+json.posts.id);//here I am not able to get the id
}
});
});
});
あなたは、Ajaxのエラーが発生したものを見るためにエラーハンドラを追加しようとしたことがありますか?フォームのボタン部分ですか?クリックイベントが発生していますか?多くのトラブルシューティング情報は表示されません。 [ask] – charlietfl
を参照してください。 'dataType:" json "'あなたのajaxでこれを使ってみてください。 – Ramkee
dataTypeをtextではなくjsonにすることはできません。そしてコンソールでjsonを印刷しようとしましたか? – sarath