我有一个大数据库来从 Ajax 响应中获取动态图像。我怎样才能让它快如闪电
图像采用逗号分隔形式,例如
img4.jpg、img3.jpg、img5.jpg、img7.jpg、img11.jpg、img1.jpg、img2.jpg、img3.jpg、img6.jpg、img8.jpg
我的 php 代码。
function childImgsGrid(){
$parentImgId = $_POST['parentImgId'];
$query = mysql_query("select child_imgs_id,child_imgs from parent where parent_img_id = $parentImgId")
or die(mysql_error());
$result = mysql_fetch_array($query);
$arrayOfImages = explode(",", $result['child_imgs']);
$i=1;
foreach($arrayOfImages as $nameOfImage){
echo "<li><a href='#lookbook' ><div class='view'><img src='images/slide/".$nameOfImage."'></a></li>";
}
}
对于阿贾克斯
var parentImgId = $anchor.attr("id");
var dataString = 'queryString=childImgsGrid'+'&parentImgId='+parentImgId;
var arrayOfImages = new Array();
$glob.ajax({
type: "POST",
url: "ajaxtemplate.php",
data: dataString,
cache: false,
success: function(response) {
$glob('#grid').html(response);
}
});