Reputation: 16219
Index.aspx
$(document).ready(function () {
$.ajax({
type: "POST",
url: "Index.aspx/GetData",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (msg) {
$.each(msg.d, function (index, value) {
$('#myDiv').html(value.Email);
});
}
})
return false;
});
Index.aspx.cs
[WebMethod]
public static IEnumerable<TemperatureEntity> GetData()
{
//return array data
I have traverse through array and want to display it in tabular format on html like email,phonenumber.
![]()
Upvotes: 0
Views: 1203
Reputation: 4261
If you want to do it exaclty on the client side then check the slice()
jQuery function
You should modify your code as following:
var slicedData = msg.d.slice(0, 10);
$.each(slicedData, function (index, value) {
var html = $('#myDiv').html();
html += value.Email;
html += value.PhoneNumber;
$('#myDiv').html(html + '<br />');
});
But if you can modify the resulting array on the server side - do it on server side with Linq
method Take(10)
;
Upvotes: 1