我在這段代碼中遇到了問題。 json不會允許雙引號結果。恩。如果我有結果(一個悲傷的「故事」)json不會解析它。Ajax Json不會允許雙重結果
$('.loader1').show();
$.ajax({
url: "findBook.php?action=populatemyacademy&bookCatId="+parentCategoryId+"",
cache: false,
dataType: "json",
success: function(data) {
$('.loader1').hide();
$.each(data.items, function(i,item){
$("#myAcademy").append('<div class="nameWrapper"><input name="checkMeM" type="checkbox" value="'+item.bookId+'"/><span title="'+item.bookName+'" class="checkBoxSpan">'+item.bookName+'</span></div>');
});
}});
以下是我在我的PHP腳本生成JSON
$sql = "SELECT academyBookId, title FROM academy_book WHERE academyBookCategoryId = $bookCatId AND academyId = $academyId";
$qPopulateAcademy = mysql_query($sql, $dbConMain) or die(__LINE__.' '.$sql.' '.mysql_error());
while($rPopulateAcademy = mysql_fetch_array($qPopulateAcademy)){
$rows[] = array('bookId' => $rPopulateAcademy [0], 'bookName' => $rPopulateAcademy [1]);
}
$jsdecode = json_encode($rows);
echo "{items:$jsdecode}";
爲什麼這會降低投票率? – Ben 2011-03-08 02:28:12
@Ben:這就是我試圖弄清楚,我的問題似乎不相關? – andsien 2011-03-08 02:29:33
這不是100%清楚,但它是一個值得回答的問題。無論如何,有人反對你。 – Ben 2011-03-08 02:35:23