利用Ajax增删改Sharepoint List Item


在使用一个工具的是想要在本地的HTML文件或者JS,修改Sharepoint List中的数据。

如下是找到的方法。不知道还有其他方法没。IE中可以使用。记得加载Jquery。

如果是Chrome 浏览器需要disable-web-security

比如需要在CMD下面这麽打开浏览器 chrome.exe --disable-web-security

或者在快捷方式的Target里面加入如图(我的是QQ浏览器,Webkit内核):

增删改:


 



 

Batch Method Cmd使用参考:

https://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems(v=office.12).aspx

<html>
<head> 
<script type="text/javascript" src="jquery-2.1.4.min.js">
script>
<script type="text/javascript">
function getItems(siteUrl, listName,query,viewFields,rowLimit,queryOptions)
{
    var soapEnv =
        '<?xml version="1.0" encoding="utf-8"?>'+
        ''+
            'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '+
            'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> '+
          ''+
            ''+
              '' + listName + ''+           
              '' + query + ''+
              '' + viewFields + ''+
              '' + rowLimit + ''+
              '' + queryOptions + ''+
              //'' + webID + ''+
            ''+
          ''+
        '';
    
    $.ajax({
        url: siteUrl + "/_vti_bin/lists.asmx",
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        error: printError,
        complete: processResult,
        contentType: "text/xml; charset=\"utf-8\""
    });
}

function printError(XMLHttpRequest, textStatus, errorThrown)
{
  alert("There was an error: " + errorThrown + " " + textStatus);
  alert(XMLHttpRequest.responseText);
}

function processResult(xData, status) 
{
var liHtml ='';
  $(xData.responseXML).find("z\\:row,row").each(function() 
  {

    liHtml += "

" + $(this).attr("ows_Title") + "

"; }); $("#Title").html(liHtml); } var siteUrl = 'http://xxxx'; var query=''+ //' '+ // ''+ // ''+ // ' 26'+ // ''+ // ''+ ''; var viewFields=''; var queryOptions=''; var rowLimit=10; //var viewName="AllItems"; var listName='xxxx'; getItems(siteUrl, listName,query,viewFields,rowLimit,queryOptions); script> head> <div id='Title'>div> html>

MSDN参考:

https://msdn.microsoft.com/en-us/library/lists.lists.getlistitems(v=office.12).aspx