Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

REST API and SP List

Posted on 2014-08-02
5
Medium Priority
?
215 Views
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="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
0
Comment
Question by:Isaac
  • 2
  • 2
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40236731
0
 
LVL 5

Author Comment

by:Isaac
ID: 40236757
I actually don't need that file and took that out and still nothing rendered....
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40236768
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
 
LVL 5

Author Comment

by:Isaac
ID: 40242153
Good Catch!  Thanks!
0
 
LVL 5

Expert Comment

by:Robin Hall
ID: 40242155
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

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 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