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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:49:10+00:00 2026-05-23T15:49:10+00:00

I am using jQuery, AJAX and PHP to update the contents of a drop

  • 0

I am using jQuery, AJAX and PHP to update the contents of a drop down box on an event. My code currently triggers the event and uses AJAX to call a PHP function which goes to the database and gets the records associated with each member of the drop down.

I can currently return this 2-dimensional array (an array of records with an array of columns in each one) back to my jQuery function but I am at a loss as to how to convert the array into something which I can use.

jQuery code to call AJAX:

    var element= $('select[name=elementName]');
    var data = 'inData=' + element.val();

    // Call AJAX to get the info we need to fill the drop downs by passing in the new ID
    $.ajax(
    {
        type: "POST",
        url: "ops.php",
        data: "op=getInfo&" + data,
        success: 
        function(outData) 
        {   
            // WHAT DO I DO HERE TO CONVERT 'outData' INTO A 2-DIMENSIONAL jQUERY ARRAY??
        },
        error:
        function()
        {

        }
    }); 

PHP code:

$sqlResults= mysql_query("SELECT data FROM table WHERE id='".$_POST['inData']."'"); 

$outData = array();

// Fill the data array with the results
while ($outData[]= mysql_fetch_array($sqlResults));

// echo the data to return it for use in the jQuery file
echo $outData;

The code posted is working fine – I just don’t know how to read ‘outData’ in jQuery.

Thanks in advance for any help!!

  • 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-23T15:49:10+00:00Added an answer on May 23, 2026 at 3:49 pm

    JSON can do the trick, but why not look at it from another angle?

    If you’re pinging PHP to get updated info, just have PHP output the option values you want in your select box. Then use the HTML return of jQuery AJAX to .html() the result into your select element.

    There’s a couple of different ways to skin a cat, and I would submit that this much easier approach is going to gain you extra time to do more jQuery wizardry.

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

Sidebar

Related Questions

I'm using the JQuery AJAX function to deliver data to a PHP doc. Currently,
Interested in building my own drag'n'drop file uploader using JQuery/AJAX/PHP. Basically I want a
So, I'm trying to learn Jquery/AJAX using an array to execute and update code
I'm posting data using jquery/ajax and PHP at the backend. Problem being, when I
I have a form what jQuery sents for me using Ajax to php. For
I have a website that uses ajax jquery and facebox. Demo here : http://temp.nevergone.eu/facebox.php
I need to update a section on my site frequently using ajax, jquery, and
I am performing a simple AJAX() request using Jquery (Google hosted 1.7.1 jquery.min.js code)
I am currently writing an Edit Account module. Using jQuery.post(); I can successfully update
While I was trying to refresh page contents dynamically using Ajax/JQuery, I have learned

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.