As we know sharepoint already provide some sevice for user, we needn‘t write CAML to query list every time, sharepoint web service have enough methods, it is easy and fast, suggest to call sharepoint serivice.
<script type="text/javascript"> var isIE = (navigator.appName.toLowerCase().indexOf(‘netscape‘) == -1); $(document).ready(function() { ExecuteOrDelayUntilScriptLoaded(makeSoapCall, ‘sp.js‘); }); function makeSoapCall(){ var soapEnv = "<soap:Envelope xmlns:xsi=‘http://www.w3.org/2001/XMLSchema-instance‘" + " xmlns:xsd=‘http://www.w3.org/2001/XMLSchema‘ xmlns:soap=‘http://schemas.xmlsoap.org/soap/envelope/‘> <soap:Body> <GetListItems xmlns=‘http://schemas.microsoft.com/sharepoint/soap/‘> <listName>" + "hr" + "</listName> <viewName></viewName> <query></query> <viewFields></viewFields> <rowLimit></rowLimit> <queryOptions><QueryOptions xmlns=‘‘><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><ViewAttributes Scope=‘RecursiveAll‘/></QueryOptions></queryOptions> </GetListItems> </soap:Body> </soap:Envelope>"; $.ajax({ url:"HTTP://DEV-SP/_vti_bin/Lists.asmx", type: "POST", dataType: "xml", data: soapEnv, complete: processResult, contentType: "text/xml; charset=\"utf-8\"" }); } function processResult(xData, status) { var result; if (isIE) result = xData.responseXML else result = xData.responseText try { if (status == "success" && result){ $(result).find("rs\\:data").each(function() { alert($(this).attr("ItemCount") + " Items found."); }); } } catch (e) { alert(e); } } </script>
Links :
Calling the SharePoint 2010 GetListItems web services with Jquery
jQuery Call web services(SOAP) in SharePoint 2013,布布扣,bubuko.com
jQuery Call web services(SOAP) in SharePoint 2013
原文:http://blog.csdn.net/tristan_dong/article/details/22387015