这是我在 PHP 中的内容:
$arrayresults = array();
while($popularbrushesrow = mysql_fetch_array($popularBrushes)){
$arrayresults[] = '<a href="brushdescription.php?id='.$popularbrushesrow['bd_brushid'].'"><img class="slideImg" alt="'.$popularbrushesrow['bd_brushname'].'" title="'. $popularbrushesrow['bd_brushname'].'" src="'.$popularbrushesrow['bd_imagefilepath'].'" /></a>';
}
echo json_encode($arrayresults);
现在,jQuery:
$.ajax({
type:'GET',
url:'getDataForSlide.php',
data:"limit="+limit+"&required="+required,
dataType:"json",
cache:true,
success: function(result){
var arrayFromPHP = JSON.parse(result);
alert(arrayFromPHP);
}
})
有人可以帮我吗。在 JSON 中形成数组的正确方法是什么?