When you make a SharePoint order, you often encounter problems with the limitations of your development tools, such as the usual companies restricting access to servers and deployment, and many of the developments are only available on the client side. There is a good solution in SharePoint2010 (see the http://www.cnblogs.com/johnsonwong/archive/2011/05/13/2044993 SharePoint Client Programming series for details). HTML), but in the SharePoint2007 is not so easy to use, specific problem analysis, this article is to solve the problem of how to access SharePoint data in JavaScript through WebService.
First you need to download the JavaScript API package from here (HTTP://DARRENJOHNSTONE.NET/DOWNLOAD/12)
Refer to the second JS, which has two libraries, one package is to deal with the core library Spapicore.js, another package provides most of the calls to the interface Spapi_lists.js
<script src= "Spapi_core.js" ></script>
<script src= "Spapi_lists.js" ></script>
The most commonly used interface methods are GetListItems (ListName, viewName, query, ViewFields, Rowlimit, Queryoptions, WebID)
The following is a common problem encountered during the SPD custom development process, obtaining user information:
function Getcurrentuserstat ()
{
var lists = new spapi_lists (');
var items = lists.getlistitems (
' UserInfo ',
', ',
' <query><where><eq><fieldref Name = "ID"/><value type= "Counter" > ' + _spuserid + ' </Value></Eq></Where></Query> ', Query
' <viewfields><fieldref name= ' Department '/></viewfields> ',
1,//Rowlimit
' '//Queryoptions
);
Information can be obtained by processing the returned XML file
if (items.status = =)
{
var rows = items.responseXML.getElementsByTagName (' Z:row ');
if (rows.length = = 1)
{
var dep = Rows[0].getattribute (' ows_department ');
Return Rows[0].getattribute (' ows_department ');
}
The call to this method is to send the request synchronously, and if you want to learn more about the value of the property when you debug it, you can view the returned results through alert (items.responsetext).
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/