Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

Am new in Jquery pls help me to this

Code :

var AddData;
                    $.each(GetStudent, function (i, item) {
                        AddData = [{ Category: "Category", StudentCode: item.StudentCode, StudentAddress: item.StudentAddress, StudentGrade: item.StudentGrade, StudentName: item.StudentName, EmployeesCount: 65 }];
                        debugger;
                    });


here
GetStudent
will return two rows from the database i want stored that rows with in
AddData
, in this code return last record only , i want to return all data , how to do that

Thanks

What I have tried:

tried in google from yesterday
Posted
Updated 20-Feb-17 19:04pm

try this
var AddData = [];
      $.each(GetStudent, function (i, item) {
          AddData.push({ Category: "Category", StudentCode: item.StudentCode, StudentAddress: item.StudentAddress, StudentGrade: item.StudentGrade, StudentName: item.StudentName, EmployeesCount: 65 });
      });


use JavaScript Array push() Method[^] to append the data in an array.
 
Share this answer
 
Comments
prasanna.raj 21-Feb-17 1:14am    
super working thank u ...
Karthik_Mahalingam 21-Feb-17 1:15am    
welcome prasanna
That AddData has to an array in order to hold multiple values:
var AddData = [];
then inside the each loop, add each item to it by:
AddData[i] = your_row;
 
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