像这样的jquery轮切的图片,图片是固定,
<SCRIPT type=text/javascript>
$("#slide").jdSlide({
width: 766 ,
height: 250,
pics: [{
src:
(screen.width >= 1200) ? "images/a1.jpg" : "images/a1.jpg",
href: "http://www.baidu.com",
alt: "",
breviary: "#",
type: "img"
}, {
src:
(screen.width >= 1200) ? "images/a2.jpg" : "images/a2.jpg",
href: "#",
alt: "",
breviary: "#",
type: "img"
}, {
src:
(screen.width >= 1200) ? "images/a3.jpg" : "images/a3.jpg",
href: "#",
alt: "",
breviary: "#",
type: "img" }, {
src:
(screen.width >= 1200) ? "images/a4.jpg" : "images/a4.jpg",
href: "#",
alt: "",
breviary: "#",
type: "img"
}]
})
</SCRIPT>
现在我改成AJAX的,
$(document).ready(function () {
$.ajax({
url: "Function/ChangePic.ashx",
data: { "val": "index" },
type: "get",
datatype: "json",
success: function (list) { var dataobj = eval("(" + list + ")");
var html = "[";
var row = 0;
$.each(dataobj.count, function (idx, item) {
row = item.count;
});
$.each(dataobj.pics, function (idx, item) {
html += "{src:\"" + item.src + "\",href:\"" + item.href + "\",alt:\"\",breviary: \"#\",type: \"img\"}";
if (idx < (row - 1)) {
html += ",";
}
});
html += "]";
$("#slide").jdSlide({
width: 766,
height: 250,
pics: html
});
}
});
});就是没用,页面显示 一个src未定义,href未定义
<SCRIPT type=text/javascript>
$("#slide").jdSlide({
width: 766 ,
height: 250,
pics: [{
src:
(screen.width >= 1200) ? "images/a1.jpg" : "images/a1.jpg",
href: "http://www.baidu.com",
alt: "",
breviary: "#",
type: "img"
}, {
src:
(screen.width >= 1200) ? "images/a2.jpg" : "images/a2.jpg",
href: "#",
alt: "",
breviary: "#",
type: "img"
}, {
src:
(screen.width >= 1200) ? "images/a3.jpg" : "images/a3.jpg",
href: "#",
alt: "",
breviary: "#",
type: "img" }, {
src:
(screen.width >= 1200) ? "images/a4.jpg" : "images/a4.jpg",
href: "#",
alt: "",
breviary: "#",
type: "img"
}]
})
</SCRIPT>
现在我改成AJAX的,
$(document).ready(function () {
$.ajax({
url: "Function/ChangePic.ashx",
data: { "val": "index" },
type: "get",
datatype: "json",
success: function (list) { var dataobj = eval("(" + list + ")");
var html = "[";
var row = 0;
$.each(dataobj.count, function (idx, item) {
row = item.count;
});
$.each(dataobj.pics, function (idx, item) {
html += "{src:\"" + item.src + "\",href:\"" + item.href + "\",alt:\"\",breviary: \"#\",type: \"img\"}";
if (idx < (row - 1)) {
html += ",";
}
});
html += "]";
$("#slide").jdSlide({
width: 766,
height: 250,
pics: html
});
}
});
});就是没用,页面显示 一个src未定义,href未定义
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货