REST API and SP List

Posted on 2014-08-02
Last Modified: 2014-08-05
I've been looking at this for a few hours and can't figure out what the problem is.  I'm using REST to retrieve data from a list and then display it on a page but the page is always blank.  Any ideas?

<script type="text/javascript" src="" language="javascript"></script>

<script language="text/javascript">
//wait until page has been loaded completely

$(document).ready(function() {
//use the getJSON mehtod of Jquery
$.getJSON("",function(data) {
//prepare HTML to render output to DIV resultarea
            var html = "";
            html = html+"<table border='2'>";
//iterate through all returned list items
$.each(data.d.results, function(i,result) {

//get item property

var strTitle = result.Title;
//add property to HTML      

				html += "<tbody><tr><td align='center'><h3>Title</h3></td></tr><tr><td width='*'>"+strTitle+"</td></tr></tbody>"; 
//finally close table and render HTML to DIV resultarea
            html += "</table>";



<div id="resultarea" width="250px" height="300px"></div>

Open in new window
Question by:Isaac
    LVL 58

    Expert Comment

    LVL 5

    Author Comment

    I actually don't need that file and took that out and still nothing rendered....
    LVL 58

    Accepted Solution

    Always eliminate the obvious

    <script language="text/javascript">

    Change language to type

    Also this returns a 404
    LVL 5

    Author Comment

    Good Catch!  Thanks!
    LVL 5

    Expert Comment

    by:Robin Hall

    I tend to use Form Web Parts if I'm putting code on a page as content editor web parts can sometimes cause problems.

    I think your main issue would be what Gary pointed out.  The Rest Service returning an error.  I used the most basic service on my sharepoint server, http://server/_vti_bin/listdata.svc, and I was able to succesfully get back a full list of my Lists.  Trying it on your website,, resulted in a generic "An error has occurred on the server" message.  

    Try it yourself to see if it works for you.  If you get the message, chase down what it is saying in the logs.  

    This ISSUE came up a few times when I tried to search for what could be causing your error, but without the logs, I couldn't tell if this is your issue or not.

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
    There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now