XMLHTTP offers the Web developer for SharePoint™ Team Services from Microsoft an efficient way to post commands to the server. It becomes particularly handy when you need to execute commands on the server without leaving the current, calling script block on the client. In the case of several remote procedure call (RPC) methods described in the SharePoint Team Services SDK—for example, ExportList, Display, or RenderView—the server's response comes in the form of XML data that is displayed in the browser; but XMLHTTP and the XML Document Object Model (DOM) offer the ability to work with this data within script. After commands have been posted to the server through the use of an XMLHTTP object, the XML Document Object Model can be used to work with the server's response.
XMLHTTP can be used with native SharePoint Team Services protocols, including the Administrative protocol, the URL protocol, SharePoint Team Services RPC protocol, and the Collaborative Application Markup Language (CAML) Batch Manager. It can also be used to implement Microsoft® Active Server Pages (ASP) in the context of lists. Whichever protocol you are using, you need to perform the following tasks:
- Construct the string to post, in keeping with the protocol's syntax. If necessary, use the escape characters for the given script language.
- Create an XMLHTTPRequest or a ServerXMLHTTPRequest object, as well as a DOMDocument object in order to work with the response.
- Use the XMLHTTP open method to establish a connection with the server.
- Use the send method to post the command string.
- Assign the XMLHTTP response to the DOMDocument object for processing.
Note: The examples in this article assume that you have already installed the Microsoft XML Core Services (MSXML) 4.0, formerly called the Microsoft XML Parser, on the client. You can install the Core Services from MSDN Downloads.
|