我需要帮助使用SP服务(Jquery)构建HTML表



我正在使用SPServices从列表中获取一些数据,如下所示:

 listSiteTabURLSalesTool = 'http://myServer';
        $().SPServices({
        operation: "GetListItems",
        webURL: listSiteTabURL, 
        listName: 'Follow',
        async: false,
        CAMLQuery:"<Query><Where><Eq><FieldRef Name='Location'/><Value Type='Text'>" + store  + "</Value></Eq></Where></Query>",
        CAMLViewFields:"<ViewFields><FieldRef Name='Title'/><FieldRef Name='Location'/></ViewFields>",
        completefunc: function (xData, Status) {

    $(xData.responseXML).find("[nodeName='z:row']").each(function() { 
              var title = $(this).attr("ows_Title"); 
             var store = $(this).attr("ows_Location"); 
             var data = title + "-" + store;

            });
              $("#idfollowup").append(data);
          }
         });

但我想构建这个表,将其与数据表插件一起使用:

<div id="idfollowup">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
    <thead>
        <tr>
            <th>Titlee</th>
            <th>Location</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Title</td>
            <td>Location</td>
        </tr>
    </tbody>
</table>
</div>

如有任何帮助,我们将不胜感激。

感谢

您应该建立要发出的标记,而不仅仅是列的值。类似这样的东西(未经测试,可能不完全正确):

         var title = $(this).attr("ows_Title");
         var store = $(this).attr("ows_Location");
         var data = "<tr><td>" + title + "</td><td>" + store + "</td></tr>; 

您还将数据附加到封闭的div,而不是其中的表

$("#idfollowup table").append(data);

最新更新