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

  • SEARCH
  • Home
  • 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 7893529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:09:21+00:00 2026-06-03T07:09:21+00:00

What I missing about posting to ActionMethods to pull data here ? I need

  • 0

What I missing about posting to ActionMethods to pull data here ?

I need to do a simple javascript/jquery call to an ActionMethod that will populatel my drop down menu with data from my Json object of type IQueryable ( or List ).

So I tried two options:

    function populateuUsers(id) {
    $.post("/User/GetUsersJson/", { id: id }, function (data) {
        if ($.isEmptyObject(data)) {
            alert("Empty");

        }

        $.each(data, function (item) {
            alert(item);
            $("#user-list").append(
                $("<option></option>").text(data[item].FullName).val(data[item].Id)
                );
        });

    }, "json");
}

I get an error that “data is undefined”

Then I tried:

    function populateUsers(id) {
    $.ajax({
        type: 'post',
        datatype: 'json',
        url: "/User/GetUsersJson/" + id,
        success: function (data) {
            alert(data);
            $.each(data, function (item) {
                alert(item);
                $("#users-list").append(
                    $("<option></option>").text(data[item].FullName).val(data[item].Id));

            });
        },
        error:function()
            {
                alert(data);
            }

    });
}

Doesn’t work either.
Something to note…I set break points and did verify that data in GetUsersJson Action method User controller gets properly populated and returned to the javascript function.

Why is it not working then ? Why is “data undefined” and it acts like there nothing returned ?

Thank you in advance.

  • 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-06-03T07:09:22+00:00Added an answer on June 3, 2026 at 7:09 am

    Inside the anonymous function that you’re passing to $.each, data is not defined. Instead you should pass two variables to that function. Something like:

    $.each(data, function (key, item) {
        alert(item);
        $("#users-list").append(
            $("<option></option>").text(item.FullName).val(item.Id));
    
    });
    

    http://api.jquery.com/jQuery.each/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As I'm writing JavaScript I'm always missing some fairly basic language features that JavaScript
I think there is something I'm missing about memory management. Here's the code: NSString
What is that I'm missing about this snippet of code? public class Zero<N extends
Okay, I must be missing something utterly simple here, because I've been googling for
I just found out, that one of my test files is missing about 20
I seem to be missing something about LINQ. To me, it looks like it's
I think I am missing something about the sphinx extension for doctest. The typical
I'm wondering if I'm missing something about Java Beans. I like my objects to
I've seen the other threads about missing split function but I didn't want to
Inspired by another question asking about the missing Zip function: Why is there no

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.