Created
February 21, 2014 02:05
-
-
Save faisal-w/9127478 to your computer and use it in GitHub Desktop.
Another example simple of JQuery REST call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#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