C# 如何在jcarousel中添加项目?在C中#

C# 如何在jcarousel中添加项目?在C中#,c#,jquery,html,jcarousel,C#,Jquery,Html,Jcarousel,我想使用c#Webmethod+jqueryajax在jcarousel中添加项 为此,我制作了如下内容: $("#mycarousel").empty(); var element =jQuery('#mycarousel'); $.ajax({ url: "Home.aspx/GetProjectData", type: "POST", dataType: 'json',

我想使用c#Webmethod+jqueryajax在jcarousel中添加项

为此,我制作了如下内容:

 $("#mycarousel").empty();
        var element =jQuery('#mycarousel');
        $.ajax({
            url: "Home.aspx/GetProjectData",
            type: "POST",
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            data: "{}",
            async: false,
            success: function (response) {
                if (response.d != null) {
                    //$.each(response.d, function (i, response) {
                    $("#mycarousel").html('response.d');
                    element.jcarousel(
                       {
                           pager: true,
                           visible: 6
                       });
                }
                else {

                }
            },
            error: function (xhr) {
            }
        });
 [WebMethod]
        public static List<string> GetProjectData()
        {
           // here i have 3 list in returnvalue
            foreach (var item in returnvalue)
            {
                var classvalue = item.Soid + "|"
                           + item.ProjectTitle + "|"
                           + item.Role + "|"
                           + item.StartDate + "|"
                           + item.EndDate + "|"
                           + item.Location.Country + "|"
                           + item.Location.State + "|"
                           + item.Location.City + "|";
                string Template = "<li><img src='../Images/DefaultPhotoMale.png' class='"+ classvalue + "' width='40' height='40' alt='image'/></li>";
                list.Add(Template);
            }
            return list;

        }
我的Html类似于:

<div>
            <ul id="mycarousel" class="jcarousel-skin-tango" style="float: left">
            </ul>
        </div>
webmethod是这样的:

 $("#mycarousel").empty();
        var element =jQuery('#mycarousel');
        $.ajax({
            url: "Home.aspx/GetProjectData",
            type: "POST",
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            data: "{}",
            async: false,
            success: function (response) {
                if (response.d != null) {
                    //$.each(response.d, function (i, response) {
                    $("#mycarousel").html('response.d');
                    element.jcarousel(
                       {
                           pager: true,
                           visible: 6
                       });
                }
                else {

                }
            },
            error: function (xhr) {
            }
        });
 [WebMethod]
        public static List<string> GetProjectData()
        {
           // here i have 3 list in returnvalue
            foreach (var item in returnvalue)
            {
                var classvalue = item.Soid + "|"
                           + item.ProjectTitle + "|"
                           + item.Role + "|"
                           + item.StartDate + "|"
                           + item.EndDate + "|"
                           + item.Location.Country + "|"
                           + item.Location.State + "|"
                           + item.Location.City + "|";
                string Template = "<li><img src='../Images/DefaultPhotoMale.png' class='"+ classvalue + "' width='40' height='40' alt='image'/></li>";
                list.Add(Template);
            }
            return list;

        }
[WebMethod]
公共静态列表GetProjectData()
{
//这里我有3个返回值列表
foreach(returnvalue中的var项)
{
var classvalue=item.Soid+“|”
+item.ProjectTitle+“|”
+项目.角色+“|”
+item.StartDate+“|”
+item.EndDate+“|”
+item.Location.Country+“|”
+item.Location.State+“|”
+item.Location.City+“|”;
字符串模板=“
  • ”; 列表。添加(模板); } 退货清单; }
    但问题是,我不能在jcarousel中看到图像,我只能看到白色的框,我不能看到里面的图像,为什么


    我不确定,但您是否需要像这样附加元素:

    var listItem = $(response.d); //I'm guessing reponse.d is your returned li
    element.append(listItem);
    

    啊,那么你应该试着去掉回复中的引号。d(我以为它只返回了一个li-没有正确阅读问题!)还有图像是否存在,查看源代码并尝试浏览图像srcok,我创建的新问题在这里: