$.ajax({ type:"get", url:spanUrl, dataType:‘jsonp‘, jsonpCallback:‘jsonp‘,//jsonp数据,需要数据库提供这个jsonp格式 success:function(selDate){ var htmlStr1 = ‘<a href="details.html?serialNumber={id}" class="item">‘+ ‘<img src="{picUrl}" class="pic">‘+ ‘<p>‘+ ‘<strong>{model} {title}</strong>‘+ ‘</p>‘+ ‘<img src="images/btn-detail.png" class="detail"></a>‘, arr1 = []; if(selDate.length==0){ $(".noData").css(‘display‘,‘block‘); }else{ console.log(selDate) for(var i=0;i<selDate.length;i++){ var o=selDate[i], t=htmlStr1.replace(‘{id}‘, o.serialNumber) .replace(‘{picUrl}‘, o.categoryimageOn) .replace(‘{model}‘, o.model) .replace(‘{title}‘,o.productFamily); arr1.push(t); } $("#part1").html(arr1.join(‘‘)) } } })
时间: 2024-10-27 18:14:07