2012-03-27 110 views
0

我使用SPServices得到一些数据从一个列表,像这样:我需要帮助建立HTML表格与SP服务(jQuery的)

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> 

任何帮助,将不胜感激。

感谢

回答

2

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

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

你也该数据附加到封闭的DIV,而不是里面的桌子。所以