Just want to read a list using Javascript

I have been searching the internet and trying sample code for a couple of weeks trying to find a simple solution to what should be a simple problem without any luck.  I don't want to do anything fancy with updating lists, creating new list items,connecting to remove servers etc.   I cannot use any non-standard libraries, add-ins, etc just out of the box  SharePoint 2010.   I know the name of the list and the name of the field obviously, so I don't need a clever solution to display all of the fields on a list with their attributes or something that requires I build a new web service, etc.

 I just need to iterate through reading the existing records in an existing list in SharePoint 2010 on a local instance into my javascript program running in a standard ASPX page.  I want to hard code the list name and the field name into the code and retrieve the data from the list.   That is all the solution needs to do.  Extra style points for simplicity.  I am new to SharePoint, but reasonably conversant in Javascript.  Just need some help in understanding what code to drop into my ASPX page.
GaryDearingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jayaraja JayaramanSharepoint Architect ConsultantCommented:
i would suggest you to use data viewer webpart to achieve ur functionality ,, making it more easier
0
GaryDearingAuthor Commented:
Thanks for your quick update, but that does not seem accomplish what I need to do.   The goal is not to just display the records.  I can do that in any number of ways within SharePoint.  The goal is to read the records in the list into my Javascript program so that I can do other things to the data.

My question is very basic. I want to hardcode the name of an existing list and an existing field into some javascript code to retrieve the data in that field from the list.  I looking for what I assume are just a relatively small number of lines of code to drop into my ASPX page.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jayaraja JayaramanSharepoint Architect ConsultantCommented:
if you wanna use javascript then the pretty straight fwd way is using jquery , guess it fits ur needs

use a content editor webpart and write ur scirpt there, refrenceing jquery min.js
en eg would be below:


<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>Tasks</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: processResult,
            contentType: "text/xml; charset=\"utf-8\""
        });
    });

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

<ul id="tasksUL"/>

Open in new window

0
GaryDearingAuthor Commented:
Thanks again for the quick response.  I found this exact example on Google about a week ago but cannot get it to work.  When I run it, I get an unterminated string literal error on this section.

"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                        <listName>Tasks</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='Title' /> \
                           </ViewFields> \
                        </viewFields> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";
0
GaryDearingAuthor Commented:
nn
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.