![](/img/trans.png)
[英]Getting a hyperlink field/column to display data as a hyperlink from a SharePoint List, using JavaScript and jQuery
[英]Getting list data from SharePoint 2010 site using Jquery
我正在尝试使用 JQuery 从 sharepoint 站点获取列表数据,但还没有返回任何内容,firebug 中也没有错误。 任何线索有什么问题?
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Action Items</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: "http://my_site/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
});
function processResult(xData, status) {
$(xData.responseXML).find("z\\:row").each(function() {
console.log("aaaa");
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
}
就在你排队之后
function processResult(xData, status) {
添加这样的警报:
alert(xData.responseText);
这将向您展示调用 GetListItems 后返回的内容。
另外,您应该更改此行:
$(xData.responseXML).find("z\\:row").
对此:
$(xData.responseXML).find("[nodeName='z:row']")
这在浏览器中更可靠。 (见我的博文: http://sympmarc.com/2009/11/08/sharepoints-web-services-jquery-and-the-zrow-namespace-in-safari-and-chrome/ )
As Rob Windsor mentions in his answer, I've got many of the SharePoint Web Services wrapped with jQuery to make them easier to use in my SPServices jQuery library . 我建议您尝试一下,因为您不必做太多工作。
我强烈建议您使用客户端 object model 而不是 Web 服务。 更丰富的功能,更容易使用。
如果您真的想使用 Web 服务,那么我建议您查看SPServices 项目。
您应该处理 ajax success
事件,而不是完成事件。 完整的事件没有那个签名。
http://api.jquery.com/jQuery.ajax/
完成(jqXHR,文本状态)
成功(数据,文本状态,jqXHR)
也许您违反了同源策略。
检查运行脚本的当前 url 是否以http://my_site/
开头
希望这可以帮助。 干杯
将processResult
function 放入$(documnet).ready
并检查
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.