Populate table with JQuery

Posted by Talkar on Stack Overflow See other posts from Stack Overflow or by Talkar
Published on 2012-12-11T08:55:09Z Indexed on 2012/12/11 23:04 UTC
Read the original article Hit count: 274

Filed under:
|
|
|

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... } ]

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html