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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:09:00+00:00 2026-05-28T02:09:00+00:00

I have a dynamic URL (http://domain.com/getUsers.php?team=1) that if its manually accessed, returns some Json

  • 0

I have a dynamic URL (http://domain.com/getUsers.php?team=1) that if its manually accessed, returns some Json objects on the browser:

[{"id":1,"name":"George"},{"id":2,"name":"John"}]

*I dont have access to getUsers.php so, I cant edit this file.
*If I look at the source code of this file on my browser, I only get pure json objects without any other HTML related tags like title, body etc.

I would like to display all the json elements from into a drop-down menu on some other page(http://domain.com/index.html).

<form>
<select name="users">
<option value="">Select a person:</option>
<option value="1">George</option>
<option value="2">John</option>

</select>
</form>

What is the best way to do this with Jquery?
What is the Jquery code that I need to put on my index.html page to retrieve and display the data?

Thank you SO!

  • 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-28T02:09:01+00:00Added an answer on May 28, 2026 at 2:09 am

    Basically, the trick is to iterate over the JSON object you receive and create elements with it.

    Here’s an example of how you could do this (and here’s a fiddle: http://jsfiddle.net/ruv3M/)

        // This is to simulate the JSON you retrieved via an AJAX call
    var people = [{"id":1,"name":"George"},{"id":2,"name":"John"}],
        // Save a reference to your list of users
        $userSelect = $( '#userlist' ).find( 'select' );
    
    // Iterate over each item in the object of people you received
    for ( person in people ) {
        // create an option for each person
        $( '<option />', {
            value: people[person].id,
            text: people[person].name
        })
            // Append it to your list
            .appendTo( $userSelect ); 
    }
    

    Update: The simplest way to make an AJAX call for JSON data is with $.getJSON(). (Documentation)

    In your code, it would probably look something like this:

    // Instead of '/echo/json/', you'd use your AJAX URL
    $.getJSON( '/echo/json/', function( data ) {
        // Set data equal to our dummy people variable, since it's blank in this example
        // NOTE! This step would be unnecessary in real life, where data would already be your JSON
        data = people;
    
        // Iterate over each item in the object of people you received
        // Note: iteration should be inside this callback, so it doesn't fire till your
        // data has been returned.
        for ( person in people ) {
            // create an option for each person
            $( '<option />', {
                value: people[person].id,
                text: people[person].name
            })
                // Append it to your list
                .appendTo( $userSelect ); 
        }
    
    });
    

    http://jsfiddle.net/B2YF5/3/

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

Sidebar

Related Questions

I have a URL like http://domain.com/index.php?user=test When a user logs in, I want to
I have a css file that links to images. .test{ background: url(http://site.com/dynamic/test.jpg) no-repeat; }
I have the following url. http://domain.com/userfiles/dynamic/images/whatever_dollar_1318105152.png Everything in the url can change except the
I have the following dynamic URL: http://www.lakaweb.com/dev/cserv/index.php?a=list&car=C5&year=2012&engine=1.8-HDi in which I rewrite to http://www.lakaweb.com/dev/cserv/list/C5/2012/1.8-HDi with:
I have following url http://domain/phpfile.php/something1-param1/something2-param2/somethin3-param3 Can i rewrite it with htaccess to http://domain/phpfile.php?something1=param1&something2=para2&something3=param3 also
I have following dynamic URL http://foo.mydomain.com and I have following in my .htaccess file
i have following dynamic url... http://www.mydomain.com/v/dynamicvaluehere and i have following in my htaccess RewriteRule
I have a dynamic query that returns around 590,000 records. It runs successfully the
We have a PHP app with a dynamic URL scheme which requires characters to
I have some dynamic text contained in a div that is set to whatever

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.