Populate table with JQuery
- by Talkar
I need to populate some data into a table.
The data i have is something i get in response from my ASP.NET MVC site, when i make a json post call there. Yet i can't seem to find a way to actually display the data i get back in response.
Here is my code so far. Any help would be much appreciated:
$(document).ready(function () {
var uName = '<%= Session["UserName"].ToString()%>';
var pWord = '<%= Session["Password"].ToString()%>';
var data = { UserName:uName,Password:pWord};
$.ajax( {
type: 'POST',
url: "http://someurl.goes.here/",
crossDomain: true,
data: data,
dataType: 'jsonp',
success: function(myData) {
$.each(myData, function (index, element) {
$("#ClassTable").append('<tr><td> ' + element[0] + ' </td> <td> ' + element[1] + '</td></tr>');
})
}
});
});
myData looks like this:
[Object { IsActive = True, ObjectId=1, ObjectString="someString", etc... etc... } ]