미리 정의 된 웹 서비스를 SharePoint 서버에서 호출하려고하지만 동일한 원본 정책 문제로 인해 해결할 수 없어 솔루션을 찾을 수 없습니다. document.domain을 서버 이름과 서버 포트로 설정하려고 시도했지만 대신 이전 오류와 동일한 문제인 DOM 보안 오류 18이 발생합니다. 나는 getLists 메소드를 호출하여 작동 여부를 확인하기 위해 노력하고 있으며 코드는 자습서에서 가져온 다음 온라인으로 here에서 본 것입니다. 어떤 도움을 많이 주셨습니다. 미리 감사드립니다.동일한 출처 정책 문제와 같은 공유 SharePoint 웹 서비스 호출
내 코드는 다음과 같다 :
아약스와<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.1.js" type="text/javascript"></script>
</head>
<body>
<div>
<script type="text/javascript">
$(document).ready(function() {
document.domain = 'http://servername:serverport'
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Occupations</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
// Call web service
$.ajax({
url: "http://servername:serverport/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processListAccessResult,
contentType: "text/xml; charset=\"utf-8\""
});
});
// Process result
function processListAccessResult(xData, status) {
$(xData.responseXML).find("z\\:row").each(function() {
$("#data").append("<li>" + $(this).attr("ows_Title") + "</li>");
});
}
</script>
<ul id="data"></ul>
</div>
</body>
</html>
개요에 동의하지만 단일 출신 제한은 XML에만 적용되는 것이 아니라 JSON 및 기타 항목에도 적용됩니다. – tinyd
좋은 지적. 나는 더 정확한 XML을 만들기 위해 첫 문장을 편집했다. – Grezzo
JSON 플러그인에서 jQuery XML을 사용하고 JSONP에서 JSON을 사용할 패드를 사용할 수 있습니까? –