Skip to content

Instantly share code, notes, and snippets.

@MayurDeore
Created June 28, 2018 04:25
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Webform.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="1" style="border-collapse: collapse">
<thead>
<tr>
<th>Product Id</th>
<th>Product Name</th>
<th>Price</th>
<th>Stock</th>
<th>Status</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</form>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$(function () {
$.ajax({
url: "Default.aspx/GetData",
type: "GET",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (result) {
var data = JSON.parse(result.d);
$.each(data, function (i, v) {
$("tbody").append(
"<tr>" +
"<td> " + v.ProductID + "</td > " +
"<td> " + v.ProductName + "</td > " +
"<td> " + v.Price + "</td > " +
"<td> " + v.StockQty + "</td > " +
"<td> " + v.Status + "</td > " +
"</tr>"
);
})
}
});
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment