如何使用Orbit插件创建动态幻灯片

时间:2012-06-21 16:07:52

标签: jquery jquery-slider

我希望在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检查代码时显示此代码 enter image description here

请帮帮我。谢谢大家。

1 个答案:

答案 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>