SharePoint 2013 - Using Web Proxy
用于在SharePoint中调用其它网站服务时使用。
1. 需要引用sp.js 和 sp.runtime.js文件;
2. 需要用到SP.WebRequestInfo,SP.WebProxy,和SP.WebReponseInfo对象;
3. 例子:
(function () { // Prepare the request to an RSS source // using the GET verb var context = SP.ClientContext.get_current(); var request = new SP.WebRequestInfo(); request.set_url( "http://www.microsoft.com/en-us/news/rss/rssfeed.aspx?ContentType=FeatureStories" ); request.set_method("GET"); var response = SP.WebProxy.invoke(context, request); //response is type of SP.WebResponseInfo // Let users know that there is some // processing going on document.getElementById("stories").innerHTML = "<P>Loading stories...</P>"; // Set the event handlers and invoke the request context.executeQueryAsync(Function.createDelegate(this, successHandler), Function.createDelegate(this, errorHandler)); })();