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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:36:40+00:00 2026-05-13T05:36:40+00:00

I use jquery ajax to get data from the PHP file. data = <option>Peter</option><option>Maria</option>

  • 0

I use jquery ajax to get data from the PHP file.

data = <option>Peter</option><option>Maria</option>

I want to then use jquery to put this data after the first option

<select>
   <option>Name</option>
</select>

I cant use html() on select because then the first option will be deleted. what jquery function can I use to put them after the first one?

EDIT: i cannot use append because then when i make another request and the data is:

data = <option>Michael</option><option>Erik</option>

Peter and Maria will still be in the Select list. how can I do? I have tried to have a

<div id=addhere></div>

after the first option and then use html() but it doesn’t work. Weird. how can I solve this?

  • 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-13T05:36:40+00:00Added an answer on May 13, 2026 at 5:36 am

    Save the original options in a variable and append the AJAX response along with the original options.

    Working demo:

    http://jsbin.com/otiro (editable via http://jsbin.com/otiro/edit)

    Source:

    <select id="name">
      <option>Name</option>
    </select>
    <script type="text/javascript">
      var nameSelect = $('#name'), originalOptions = nameSelect.children();
      
      function handleAjaxResponse(response) {
        nameSelect.children().remove().end().append(originalOptions.add(response));
      }
    
      $.get("getNames.php", handleAjaxResponse);
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i use json_encode to send back data from php to jquery through ajax. and
My jQuery code (using ajax) request's data from a local php script (pgiproxy.php). This
I am trying to use jQuery's ajax functionality to update data from a web
I don't want to use jQuery, but I'd like to use Ajax to do
I don't understand one thing. If I want to get JSON data (key-value-pairs) from
I use $.ajax() to get some HTML pages from my server. The retrun contains
Is it possible to use a jQuery ajax call to perform Forms Authentication with
I use the following for a jQuery link in my <script> tags: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js Is
I want to use jQuery with a GridView which contains textboxes, but I'm stuck
I am trying to use JQuery in my ASP.Net 2.0 website in this scenario:

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.