0

我的 sharepoint 2013 平台中有一个运行良好的新闻代码,但是当我没有新闻时,横幅仍然是空的,我该如何隐藏它?这是我的代码:jquery.ticker.js 和:

<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>supported_applications</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='Title' /> \
                               <FieldRef Name='ID' /> \
                           </ViewFields> \
                        </viewFields> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";

        $.ajax({
            url: "path to.../_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 liHtml = $(this).attr('ows_ID') +":   " +$(this).attr('ows_Title')+'<br>'; var liHtml = "<li><a href='path to.../Lists/applications/DispForm.aspx?ID=" + $(this).attr('ows_ID') + "'>" + $(this).attr('ows_Title') + "</a></li>";
            $("#tasksUL").append(liHtml);}); }
</script><ul id="tasksUL"/>

有什么建议么?

4

1 回答 1

0

如果 count 为空,则隐藏包含的 html 元素。

 function processResult(xData, status) {

if( $(xData.responseXML).find("z\\:row").length==0)
{
         $("#tasksUL").hide();
}

        $(xData.responseXML).find("z\\:row").each(function() {
              // var liHtml = $(this).attr('ows_ID') +":   " +$(this).attr('ows_Title')+'<br>'; var liHtml = "<li><a href='path to.../Lists/applications/DispForm.aspx?ID=" + $(this).attr('ows_ID') + "'>" + $(this).attr('ows_Title') + "</a></li>";
            $("#tasksUL").append(liHtml);}); }
于 2014-09-08T10:09:50.627 回答