Javascript 链接到sharepoint列表

Javascript 链接到sharepoint列表,javascript,html,sharepoint,hyperlink,Javascript,Html,Sharepoint,Hyperlink,我试图编写一段代码,链接到sharepoint列表(UtilitiesContracts)并引入某些列(Client)。但是,当我运行代码时,它似乎没有链接数据。有人能发现我的代码有什么错误吗 这是加载代码时显示的内容 $(文档).ready(函数(){ var myQuery= "" + "" + "" + "" + ""; $().SPServices({ 网址:“https://ext.kier.co.uk/teams/Utilities/", 操作:“GetListItems”, a

我试图编写一段代码,链接到sharepoint列表(UtilitiesContracts)并引入某些列(Client)。但是,当我运行代码时,它似乎没有链接数据。有人能发现我的代码有什么错误吗

这是加载代码时显示的内容


$(文档).ready(函数(){
var myQuery=
"" +
"" +
"" +
"" +
"";
$().SPServices({
网址:“https://ext.kier.co.uk/teams/Utilities/",
操作:“GetListItems”,
async:false,
listName:“效用合同”,
CAMLQuery:myQuery,
CAMLRowLimit:100,
completefunc:函数(扩展数据、状态){
var liHtml=“”;
$(扩展数据.responseXML).SPFilterNode(“z:row”).each(函数(){
liHtml=liHtml++$(this.attr(“ows_客户端”)++$(this.attr(“ows_Title1”)++$(this.attr(“ows_Title2”)++$(this.attr(“ows_Title3”)+;
});
liHtml+=“”;
$(“#示例”).append(liHtml);
}
});
$('#示例')。数据表({
“dom”:“Rlfrtip”
});
});
客户
标题1
标题2
标题3

无法在本地计算机HTML文件中运行代码

您需要将下面的代码添加到SharePoint页面中才能使其正常工作

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">    
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/css/dataTables.jqueryui.min.css">
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>    
<script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script> 
<script src="https://www.datatables.net/release-datatables/extensions/ColReorder/js/dataTables.colReorder.js"></script>
<!--SPServices Javascript-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.min.js"></script>
<!--SpServices JavaScript get items from list 'files'-->
<script language="javascript" type="text/javascript">
  $(document).ready(function() {
    var myQuery =
      "<Query>" +
      "<OrderBy>" +
      "<FieldRef Name='Client' />" +
      "</OrderBy>" +
      "</Query>";
    $().SPServices({
      webURL: "http://sp2013/sites/team",
      operation: "GetListItems",
      async: false,
      listName: "UtilitiesContracts",
      CAMLQuery: myQuery,
      CAMLRowLimit: 100,
      completefunc: function(xData, Status) {
        var liHtml = "<tbody>";
        $(xData.responseXML).SPFilterNode("z:row").each(function() {
          liHtml = liHtml + " <tr><td>" + $(this).attr("ows_Client") + "</td><td>" + $(this).attr("ows_Title1") + "</td><td>" + $(this).attr("ows_Title2") + "</td><td>" + $(this).attr("ows_Title3")+ "</td></tr>";
        });
        liHtml += "</tbody>";
        $("#example").append(liHtml);
      }
    });
    $('#example').DataTable({
      "dom": 'Rlfrtip'
    });
  });

</script>
<table id="example" class="display" cellspacing="0" width="100%">
  <thead>
    <tr>
      <th>Client</th>
      <th>Title1</th>
      <th>Title2</th>
      <th>Title3</th>
    </tr>
  </thead>
</table>

$(文档).ready(函数(){
var myQuery=
"" +
"" +
"" +
"" +
"";
$().SPServices({
网址:“http://sp2013/sites/team",
操作:“GetListItems”,
async:false,
listName:“效用合同”,
CAMLQuery:myQuery,
CAMLRowLimit:100,
completefunc:函数(扩展数据、状态){
var liHtml=“”;
$(扩展数据.responseXML).SPFilterNode(“z:row”).each(函数(){
liHtml=liHtml++$(this.attr(“ows_客户端”)++$(this.attr(“ows_Title1”)++$(this.attr(“ows_Title2”)++$(this.attr(“ows_Title3”)+;
});
liHtml+=“”;
$(“#示例”).append(liHtml);
}
});
$('#示例')。数据表({
“dom”:“Rlfrtip”
});
});
客户
标题1
标题2
标题3

如果您想从本地访问SharePoint列表数据,我们可以使用CSOM(C#)来实现


所以我需要将我已经完成的代码放入共享点脚本编辑器中?是的,您可以将代码添加到脚本编辑器Web部件或内容编辑器Web部件中,或者直接使用SharePoint designer将其添加到页面中。我仍然没有将任何数据放入表中,你认为我连接列表的方式有什么问题吗?你可以使用IEF12开发工具来调试代码,看看是否有错误发生。