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 6569487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:37:58+00:00 2026-05-25T14:37:58+00:00

My Ajax block looks like so: $(‘#btnTest’).click(function(){ $.getJSON(‘/User/ViewMessages’,function(result) { // TODO: update the DOM

  • 0

My Ajax block looks like so:

    $('#btnTest').click(function(){
      $.getJSON('/User/ViewMessages',function(result) {
            // TODO: update the DOM with the items
            $("table#tblMessages").append("<tr><td>"+result.MESSAGETEXT+"</td><td>"+result.DATESENT+"</td>");
      });
    });

My Action in my Controller looks like such:

        public ActionResult ViewMessages()
    {
        var recipient = Convert.ToInt32(HttpContext.Session["User_Id"]);
        var query = (from m in context.Messages
                     from rec in context.Recipients
                     where rec.RECIPIENT == recipient
                     where rec.MESSAGEID == m.MESSAGEID
                     select new 
                     {
                         m.MESSAGETEXT,
                         m.DATESENT
                     }).ToList();
        return Json(query.ToList());
    }

When Debugging, my query variable returns:
{ MESSAGETEXT = “seresr”, DATESENT = {9/15/2011 11:06:45 AM} }

The thing is, my table is added with “undefined” for both my values. Where have i gone wrong? I have already added the maproute as well, but I’m still out of luck.

  • 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-25T14:37:59+00:00Added an answer on May 25, 2026 at 2:37 pm

    It looks like you’re returning a list, which will be represented in JSON as an array. So your result object is a JavaScript array rather than a single object. To loop through all the items and add a table row for each, try something like this:

    $.getJSON('/User/ViewMessages', function(result) {
        for (var i in result) {
            var row = result[i];
            $("table#tblMessages").append("<tr><td>" + row.MESSAGETEXT
                + "</td><td>" + row.DATESENT + "</td>");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ajax request that looks like this, $(#frmProducts).submit(function(){ var dataSet = $(#frmProducts).serialize();
I have a SELECT object and I'm populating it with AJAX(JQUERY). $(#setor).change(function(){ $(#loading).css(display, inline-block);
I have some jQuery that looks like this: $.ajax({ type: POST, url: /Customer/CancelSubscription/<%= Model.Customer.Id
I have some jQuery that looks like this: $.ajax({ type: POST, url: /problems/vote.php, dataType:
I have a javascript function that looks like this: function getAlerts() { $.post('getAlerts.php', function(data)
I am using JQuery UI plugin blockUI to block UI for every ajax request.
Ajax seems to give a better user experience, but I'm not so sure if
ajax tutorial on w3school at http://www.w3schools.com/ajax/ajax_database.asp In this function (function GetXmlHttpObject()), it creates a
In AJAX applications that need to poll the server in regular intervals (like a
I have a JAVASCRIPT array that looks like this: postarray['min_price'] = 120000; postarray['max_price'] =

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.