Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, i try to call a JsonResult action (getCustomers) in MVC with jquery and populate a table dynamically. The action is called but the table is not populated. This is my code

JavaScript
<table id="tbl">
         <tr>
            <td>Customer Code</td>
            <td>Customre Name</td>
         </tr>
      </table>
      <script type="text/javascript">
         $.get("getCustomers", null, BindData);
         function BindData(Customers) {
            var tbl = $("#tbl");
            for (var j = 0; j < Customers.lenght; j++) {
               var newRow = "<tr>" +
                  "<td>" + Customers[j].CustomerCode + "</td>" +
                  "<td>" + Customers[j].CustomerName + "</td>" +
                  "</tr>";
               tbl.append(newRow);
            }
         }
      </script>


i can't figure why..
Posted
Updated 21-Feb-15 21:40pm
v3
Comments
Anisuzzaman Sumon 22-Feb-15 7:14am    
check this line for (var j = 0; j < Customers.lenght; j++) {
here use
'Customers.length' instead of 'Customers.lenght' spelling mistake ,may be all the other code seems ok. :)
stibee 22-Feb-15 14:21pm    
Why you do net write this as an answer, that the this thread can be marked as resolved?
Mauro_C 22-Feb-15 9:36am    
Lol.. ehm.. thank you so much
Anisuzzaman Sumon 22-Feb-15 23:06pm    
Hi Mauro_C now mark bellow solution as answer so that the thread can be marked as resolved!

1 solution

check this line
 for (var j = 0; j < Customers.lenght; j++) {
here use
'Customers.length' instead of 'Customers.lenght' spelling mistake ,may be all the other code seems ok. :)
 
Share this answer
 

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