我希望在Jquery中创建动态幻灯片我写这段代码
var ctx = new DynamicSlideShowEntities();
var list = ctx.Pictures.ToList();
string bb = JsonConvert.SerializeObject(list);
context.Response.Write(bb);
和js代码
<script type="text/javascript">
$(function () {
$.ajax({
url: "Handler.ashx",
contentType: "application/json; charset=utf-8",
success: function (data) {
$.each(data, function (i, b) {
var str = '<img src="' + b.PicturePath + '" alt="' + b.PictureText + '"/>';
$("#featured").append(str);
});
},
dataType: "json"
});
$('#featured').orbit();
alert($("#featured img").length);
});
</script>
但是当运行项目时没有显示任何图片,但是当使用firebug检查代码时显示此代码
请帮帮我。谢谢大家。
答案 0 :(得分:0)
编写此代码
<script type="text/javascript">
$(function () {
$.ajax({
url: "Handler.ashx",
contentType: "application/json; charset=utf-8",
success: function (data) {
$.each(data, function (i, b) {
var str = '<img src="' + b.PicturePath + '" alt="' + b.PictureText + '"/>';
$("#featured").append(str);
});
$('#featured').orbit();
},
dataType: "json"
});
alert($("#featured img").length);
});
</script>