REST API and SP List

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="http://isaac.issharepoint.com/practice/Assets/jquery-1.8.2.min.js" language="javascript"></script>


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

$(document).ready(function() {
alert("hello");
//use the getJSON mehtod of Jquery
$.getJSON("http://isaac.issharepoint.com/practice/_vti_bin/ListData.svc/EmpireEngagements",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>";
            $('#resultarea').append($(html));
});

});

</script>



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

Open in new window







http://isaac.issharepoint.com/practice/Web%20Part%20Pages/restTest.aspx
LVL 5
IsaacSharePoint Client Side DeveloperAsked:
Who is Participating?
 
GaryCommented:
Always eliminate the obvious

<script language="text/javascript">

Change language to type

Also this returns a 404
http://isaac.issharepoint.com/practice/_vti_bin/ListData.svc/EmpireEngagements
0
 
GaryCommented:
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
I actually don't need that file and took that out and still nothing rendered....
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
Good Catch!  Thanks!
0
 
Robin HallSenior Web Solutions ArchitectCommented:
TheInnovator,

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, http://isaac.issharepoint.com/_vti_bin/ListData.svc/, 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.
0
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.

All Courses

From novice to tech pro — start learning today.