Go to the following Url to Create Wcf Service using REST.
Default.aspx:
<body>
<form id="form1" runat="server">
<div>
<table border="1" id="Employees">
<tr>
<td><b>UserId</b></td>
<td><b>FirstName</b></td>
<td><b>LastName</b></td>
<td><b>Salary</b></td>
</tr>
</table>
</div>
</form>
</body>
javascript:
<head runat="server">
<title></title>
<script src="jquery-1.7.min.js"></script>
<script type="text/javascript">
$(document).ready(function ()
{
$.ajax({
type: "GET",
url: "http://localhost:62153/Service1.svc/GetEmployeeList/",
dataType: "xml",
success: function (xml) {
$(xml).find('Employee').each(function () {
var id = $(this).find('UserId').text();
var firstName = $(this).find('FirstName').text();
var lastName = $(this).find('LastName').text();
var salary = $(this).find('Salary').text();
$('<tr><td>' + id + '</td><td>' + firstName + '</td><td>' + lastName + '</td><td>' + salary+'</td>').appendTo('#Employees');
});
},
error: function (xhr) {
alert(xhr.responseText);
}
});
});
</script>
</head>
Output:
No comments:
Post a Comment
Thank you for visiting my blog