Click here to Skip to main content
15,905,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
The below code working well, when table rows are below 50 and data from view to action (controller) working well. When rows are large (more than 50) it not working well and give error "object object".

What I have tried:

var Itemlist = [];
  $('table#ItemsTable tr:not(:first)').each(function () {
                var tdlist = $(this).find("td");
                var Item = { SortingOrder: $(tdlist[1]).find("input[name='SortingOrder']").val(), ClientName: $(tdlist[2]).find("input[name='ClientName']").val(), ClientNameU: $(tdlist[3]).find("input[name='ClientNameU']").val(), ClientMobile: $(tdlist[4]).find("input[name='ClientMobile']").val(), ClientEmail: $(tdlist[5]).find("input[name='ClientEmail']").val(), Balance: $(tdlist[6]).find("input[name='Balance']").val(), Bottle: $(tdlist[7]).find("input[name='Bottle']").val(), Coupon: $(tdlist[8]).find("input[name='Coupon']").val(), AreaID: $(tdlist[9]).find("#ddArea").val(), PaymentID: $(tdlist[10]).find("#ddPayment").val(), EmployeeID: $(tdlist[11]).find("#ddEmployee").val(), ClientAddress: $(tdlist[12]).find("input[name='ClientAddress']").val() };

        url: '@Url.Action("Action", "Controller", new { area = "Area" })',
                type: "POST",
                data: JSON.stringify(Itemlist),
                contentType: "application/json; charset=utf-8",
                dataType: "html"
                success: function (result) {
                error: function (Result) {
Member 15627495 9-Mar-23 1:14am    
hi !

you have a 'void' object after the 50th row. is there any 'empty' td field somewhere ?
add a method to filter for "null" Object/""

about your code :
you fetch all TDs after the header row, great !
but you call 'static elements' when you tdlist[n], then you use 'find' to a really accurate location.

it's always :
// go through a function

function get_val(Xtd,Xname){ // something near.
temp = $(Xtd).find("input[name='+Xname+']").val() ;
if(temp == Null || temp == ""){return Null;}else{
return temp ;
} }

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900