Skip to content

Instantly share code, notes, and snippets.

@faisal-w
Created February 21, 2014 02:05
Show Gist options
  • Save faisal-w/9127478 to your computer and use it in GitHub Desktop.
Save faisal-w/9127478 to your computer and use it in GitHub Desktop.
Another example simple of JQuery REST call
$("#myButton").click(function() {
var artistURL = "http://development.dlwelch.com/examples/restservice/JazzArtists.svc/json/Shirley";
var returnData = "";
$.ajax({
type: "GET",
dataType: "json",
async: true,
url: artistURL,
error: function(request, status, error) { alert(request.responseText) },
success: function(data) {
$("div#myOutput").html(" ");
returnData = "<table style='font-size:8pt;'><tr><th>Artist</th><th>Grammys</th></tr>";
for (prop in data) {
if (!data.hasOwnProperty(prop)) { continue; }
if (data[prop] != null) {
for (var i = 0; i < data[prop].length; i++) {
returnData += "<tr><td>" + data[prop][i]["FirstName"]
+ " " + data[prop][i]["LastName"] + "</td><td align='right'>"
+ data[prop][i]["Grammy"] + "</td></tr>";
}
}
}
returnData = returnData + "</table>";
$("div#myOutput").html(returnData);
}
});
return (false);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment