Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7443365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:19:08+00:00 2026-05-29T11:19:08+00:00

In controller: var jsonData = new { total = totalPages, page = pageIndex, records

  • 0

In controller:

        var jsonData = new
        {
            total = totalPages,
            page = pageIndex,
            records = totalRecords,
            rows = founduser
        };
        return jsonData;  

In View:

function listItems(col, order, page, rows) {
    $.ajax({
        type: "GET",
        url: '@Url.Content("~/User/GetUsers")',
        data: { col: col, order: order, page: page, rows: rows },
        dataType: 'json',
        success: function (response) {
            var tags = "<tr><th>Login id</th><th>First name</th><th>Middle name</th><th>Last name</th><th>Prefix</th><th>Suffix</th><th>Reset</th><th>Email</th><th></th></tr>";
            $.each(response, function (index, item) {
                    tags += "<tr id=row-" + item.UserID + ">" +
                                "<td>" + item.LoginID + "</td>" +
                                "<td>" + item.FirstName + "</td>" +
                                "<td>" + item.MiddleName + "</td>" +
                                "<td>" + item.LastName + "</td>" +
                                "<td>" + item.Prefix + "</td>" +
                                "<td>" + item.Suffix + "</td>" +
                                "<td>" + item.IsReset + "</td>" +
                                "<td>" + item.SendEmail + "</td>" +
                                "<td>" +
                                "<a href=# class='ActivateItem' data-id = " + item.UserID + " item-data = " + item.LoginID + ">Activate</a> | " +
                                "<a href=/BaseAdmin/User/Details/" + item.UserID + ">Details</a></td></tr>";
            });
            $("#table-list").html(tags);
        }
    });
};  

rows is an IEnumerable array, now how could I get the values of row and put on the table?

<table id="table-list">
</table>  

I’m able to retrieve the values, but I can’t display it using jQuery.each. Thanks for help!

Sample preview:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:19:09+00:00Added an answer on May 29, 2026 at 11:19 am

    One you return a JSON result from your controller action:

    public ActionResult Foo()
    {
        var jsonData = new
        {
            total = totalPages,
            page = pageIndex,
            records = totalRecords,
            rows = founduser
        };
        return Json(jsonData, JsonRequestBehavior.AllowGet);
    }
    

    you can loop through the rows property in your AJAX success callback:

    success: function (response) {
    var tags = "<tr><th>Login id</th><th>First name</th><th>Middle name</th><th>Last name</th><th>Prefix</th><th>Suffix</th><th>Reset</th><th>Email</th><th></th></tr>";
    $.each(response.rows, function (index, item) {
        tags += "<tr id=row-" + item.UserID + ">" +
                    "<td>" + item.LoginID + "</td>" +
                    "<td>" + item.FirstName + "</td>" +
                    "<td>" + item.MiddleName + "</td>" +
                    "<td>" + item.LastName + "</td>" +
                    "<td>" + item.Prefix + "</td>" +
                    "<td>" + item.Suffix + "</td>" +
                    "<td>" + item.IsReset + "</td>" +
                    "<td>" + item.SendEmail + "</td>" +
                    "<td>" +
                       "<a href=# class='ActivateItem' data-id = " + item.UserID + " item-data = " + item.LoginID + ">Activate</a> | " +
                       "<a href=/BaseAdmin/User/Details/" + item.UserID + ">Details</a>" +
                    "</td>" + 
                "</tr>";
        });
        $("#table-list").html(tags);
    }
    

    Things that could be improved in this code:

    • don’t use string concatenations to generate a DOM tree. Use the jQuery( html, props ) overload.
    • don’t hardcode the url of your Details anchors -> use url helpers to generate it.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the CakePHP stack in /var/www/site from one view under controller A I
I have the following in my controller: var $cacheAction = array( 'view/' => 432000,
I have got this controller: class Start extends CI_Controller{ var $base; var $css; function
I have the following code in my controller: public ActionResult Details(int id) { var
My Controller Action accepts int id. What to do when calling from View ActionLink
In controller level i used [ValidateInput(false)] and ValidateRequest=false in the view. Everything is fine
I want my controller to return the right HTTP response code when the user
function onTestComplete(content) { var url = '<%= Url.Action(JsonTest,Organization) %>'; $.post(url, null, function(data) { alert(data[name]);
I have the following app_controller in app/controller. the test function is never executed. If
JQuery code: //This passes NULL for CategoryID, CategoryName, ProductID, ProductName $(#btnPost).click(function () { var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.