通过SOAP创建指向SharePoint列表项的超链接

时间:2013-02-21 21:45:33

标签: jquery ajax soap sharepoint-2007

我有一个小的JQuery / AJAX代码块,它通过SOAP查询连接到SharePoint列表,并从列表中返回多个列的内容。我想要做的是将该输出转换为回到原始列表项的超链接。我一直在尝试使用列表项的ID来构建超链接,但列表项的ID属性似乎没有返回有效值。我做错了什么?

    <script src="/sites/someSite/Resources/jquery-1.8.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>FAQ List</listName> \
                    <viewFields> \
                        <ViewFields> \
                           <FieldRef Name='Question_x0020_Description' /> \
                           <FieldRef Name='Response_x0020_from_x0020_HQ'/> \
                           <fieldRef Name='ID'/>\
                       </ViewFields> \
                    </viewFields> \
                </GetListItems> \
            </soapenv:Body> \
        </soapenv:Envelope>";

    $.ajax({
        url: "/sites/someSite/_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() {
    var iDesc=$(this).attr("ows_Question_x0020_Description");
    var iResp=$(this).attr("ows_Response_x0020_from_x0020_HQ");
              var iID=$(this).attr("ows_ID");
            var liHtml = "<div class='question'>" + iDesc + "</div><div class='answer'><a href='/sites/someSite/Lists/FAQ%20List/DispForm.aspx?ID="+iID+"'>"+ iResp +"</a></div>";
            $("#FAQ").append(liHtml);
    });
}

有什么想法吗?

0 个答案:

没有答案