私は初心者です.jsonデータを取得する際に立ち往生しています。私data.phpでjqueryを使用してjsonデータを取得することができません
<script type="text/javascript" src="jquery-1.3.2.min_2.js">
$("document").ready(function() {
$.getJSON("data.php",function(jsondata){
$("#content").html(jsondata[0].content);
});
});
</script>
</head>
<body>
<div id="content"></div>
<div class="lg"></div>
</body>
私は、符号化の標準的な方法を使用して、データを送信しています:私は、MySQLデータベースを使用しています
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
$row = mysql_fetch_row($result);
$jsonserver[$i] = $row;
}
echo json_encode($jsonserver);
header('Content-type: application/json');
mysql_free_result($result);
// close connection
mysql_close($con);
次
は私のindex.phpです。 localhost/data.phpを開いたときにjsonデータがブラウザに表示されます。 しかし、もし私がlocalhost/index.phpを開いた場合、私はdonotに任意の出力を得ます。 説明してください。 ありがとう!
'json_encode($ jsondata)'とは何ですか? utput? – seriousdev
これは 'index.php'の完全なコードですか?あなたは 'id =" content "'を持つ要素を持っていますか? – Xint0
** Uncaught ReferenceError:マニフェストが定義されていません**これは、chrome_onでCtrl + Shift + iを押すとエラーが発生します。ただし、firebugはfirefoxでこの種のものを表示しません。 – whatf