我希望为我工作的SharePoint服务器制作一个简单的CRUD跨平台移动应用程序。 我正在使用PhoneGap处理跨平台编码 - 因此我的代码将是HTML,CSS和JavaScript。
我遇到的主要障碍是与我的SharePoint服务器进行身份验证。 许多人在网上成功地使用了AJAX调用,但是我收到以下错误:
以下是我的JavaScript代码:
我遇到的主要障碍是与我的SharePoint服务器进行身份验证。 许多人在网上成功地使用了AJAX调用,但是我收到以下错误:
XMLHttpRequest cannot load http://<DOMAIN>/_vti_bin/authentication.asmx. The request was redirected to 'http://<DOMAIN>/_layouts/15/error.aspx?ErrorText=Request%20format%20is%20unrecognized%2E', which is disallowed for cross-origin requests that require preflight.
以下是我的JavaScript代码:
function Authenticate() {
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
$("#topnavcontent").append("Creating SOAP envelope...</br>");
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>" +
"<Login xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">" +
"<username>USERNAME</username>" +
"<password>PASSWORD</password>" +
"</Login>" +
"</soap:Body>" +
"</soap:Envelope>";
$("#topnavcontent").append("Calling authenticate.asmx...</br>");
$.ajax({
url: "http://<DOMAIN>/_vti_bin/authentication.asmx",
type: "POST",
data: soapEnv,
complete: authenticationResultSuccess,
contentType: "text/xml; charset=\"utf-8\"",
error: authenticationResultError
});
}
我了解浏览器会发送一个预检OPTIONS调用。默认情况下,SharePoint网站不支持OPTIONS调用。是否有任何解决方法,例如禁用此OPTIONS调用或在SharePoint网站的webconfig中设置允许预检请求的选项?感谢您提前的帮助。
<access origin="*" />
吗? - Dawson Loudon<access origin="*" />
已经是 config.xml 的一部分了。 - DrEvans