使用Jquery获取sharepoint 2010中的列表项

时间:2015-06-18 11:56:08

标签: sharepoint sharepoint-2010

我在发布网站上使用了内容编辑器Web部件,并在库中上传了.js文件,并在内容编辑器Web部件中创建了一个链接。但得到'未定义'而不是列表内容。

<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"/> 

1 个答案:

答案 0 :(得分:0)

最佳选择使用休息电话

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;

}