使用Jquery获取sharepoint 2010中的列表项
我在发布网站上使用了Content Editor Web部件,在库中上载了.js文件,并在Content Editor Web部件中创建了一个链接。但是获取“未定义”而不是列表内容使用Jquery获取sharepoint 2010中的列表项,sharepoint,sharepoint-2010,Sharepoint,Sharepoint 2010,我在发布网站上使用了Content Editor Web部件,在库中上载了.js文件,并在Content Editor Web部件中创建了一个链接。但是获取“未定义”而不是列表内容 <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script> <script type="text/javascript">
<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>'EmployeeProfileList'</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: "http://lenovo-pc/sites/TestPublishingPortal/MVPProfilePage/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
});
function processResult(xData, status) {
var liHtml = "<li>" + $(this).attr('ows_Title') + "</li>";
alert(liHtml);
alert($(this).attr('ows_Title'));
$("#tasksUL").append(liHtml);
}
</script>
<ul id="tasksUL"/>
$(文档).ready(函数(){
var soapEnv=
" \
\
\
“员工档案列表”\
\
\
\
\
\
\
\
";
$.ajax({
url:“http://lenovo-pc/sites/TestPublishingPortal/MVPProfilePage/_vti_bin/lists.asmx",
类型:“POST”,
数据类型:“xml”,
数据:soapEnv,
完成:processResult,
contentType:“text/xml;字符集=\“utf-8”
});
});
函数processResult(扩展数据、状态){
var liHtml=“”+$(this.attr('ows_Title')+” ”;
警报(liHtml);
警报($(this.attr('ows_Title'));
$(“#tasksUL”).append(liHtml);
}
最佳选择使用rest调用
function getdata({
var returnValue = '';
$(this).spRESTCall({
method : 'Get',
list: listname,
select: "Title,Id",
expand: "Episode,Project",
orderby : "Date asc",
success: function (result)
{
if(result.data.length>0)
returnValue = result.data;
},
failure: function (data) {
alert(data.status);
}
});
return returnValue;
}