jQuery REST API Service call to GET items

To fetch the data byb making RESTful API call use below code,

//Function to Make an Ajax call to Read all items from list or API
function loadData() {
var Employees = [];
url: “http://<Site URL>/api/<API Service Name>”,
type: “GET”
}).done(function (resp) {
$.each(resp, function (index, value) {
$(“#dvmsg”).html(‘Call Completed successfully…’);
}).error(function (err) {
$(“#dvmsg”).html(‘Call Failed…’ + err.status);

Load Table data

function loadTable(emps) {
$(“#tbldetails tbody”).html(”);
var tbody = “”;
$.each(emps, function (index, value) {
tbody += ‘<tr><td><input type=”checkbox” class=”c2″></td>’;
tbody += ‘<td>’ + value.EmpNo + ‘</td>’;
tbody += ‘<td>’ + value.EmpName + ‘</td>’;
tbody += ‘<td>’ + value.Salary + ‘</td>’;
tbody += ‘<td>’ + value.DeptName + ‘</td>’;
tbody += ‘<td>’ + value.Designation + ‘</td></tr>’;

$(“#tbldetails tbody”).append(tbody);




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s