0

I tried this code and paste to the content editor in sharepoint but then nothing came out. Just a blank space. I tried to inspect the marquee is working working but it just not showing the item it suppose to show. Please help.

    <script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" type="text/javascript"></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>News</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='Title' /> \
                           </ViewFields> \
                        </viewFields> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>"; 

        $.ajax({
            url: "/_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: Result,
            contentType: "text/xml; charset=\"utf-8\""
        });
    }); 

    function Result(xData, status) {
        $(xData.responseXML).find("z\\:row").each(function() {
            var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
            $("# news ").append(liHtml);
        });
    }  
</script>               

<marquee onmouseover="this.stop();" onmouseout="this.start();">
                <ul id="news">  </ul>
</marquee>

<style>
         UL#news {
                     WIDTH: 620px;
                      OVERFLOW: hidden
         }

          UL#news LI {        
                       WIDTH: 600px;    
                       DISPLAY: inline;
                       HEIGHT: 99px;
        }
</style>

I already check the list name and field ref but still it didnt give any outcome. Any help would be appreciated. Thank you.

2
  • What is the reason you are using SOAP and not REST? And what is the reason you are using a jQuery version from july 2013? Commented Dec 14, 2016 at 7:45
  • Im just trying my luck, Im still new with this, so I just try anything that was working for as long as I can see it working and learn from this. Why? Could you guide me on this?
    – Blazeous
    Commented Dec 14, 2016 at 7:50

1 Answer 1

0

Seems there is an extra space in jquery selector
$("# news ").append(liHtml);
Update it to:
$("#news").append(liHtml);

8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.