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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:34:37+00:00 2026-05-26T10:34:37+00:00

I am calling a page that returns data like: <div id=class> <option>Value</option> <option>Value</option> </div>

  • 0

I am calling a page that returns data like:

<div id="class">
    <option>Value</option>
    <option>Value</option>
</div>

<div id="type">
    <option>Value</option>
    <option>Value</option>
</div>

I am trying to filter the data so that I can cycle through each one and insert the option values into the correct section drop down list for them. I even extended the data so that I could try .find() on it, and made it look like:

<div id="class">
    <div class="options">
        <option>Value</option>
        <option>Value</option>
    </div>
</div>

<div id="type">
    <div class="options">
        <option>Value</option>
        <option>Value</option>
    </div>
</div>

However, it still does not work. I only get the text output, and not the html elements. So my question is, how do I keep the actual html elements when I use the .filter() command? My current code is below.

$.ajax({  
    type: "POST", 
    url: "searchFunctions.php",
    data: dataString,
    success: function(data) {
        // Create jquery object from the response html
        var $response=$(data);

        // Change styles for children
        $response.filter('div').each(function(){
            $("#"+$(this).attr("id")).html($(this).find(".options"));
        });
    }
});

Please note, I did try .text() and .html() at the end of $(this).find(“.options”) with no luck. It still only returned the value portion. But it’s weird. When I used $(this).html() (no .find(“.options.”)), I could see the tags, but still not the tags…

Thanks in advance.

Yeah, never even thought about the fact that the browser would drop the option tags due to no select tag…

  • 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-26T10:34:37+00:00Added an answer on May 26, 2026 at 10:34 am

    This is because a div element can’t contain an option element in valid HTML. This will work if you wrap the options in a select rather than a div:

    <select id="type">
        <option>Value</option>
        <option>Value</option>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET page that takes some key, value data and a HttpFileCollection
After calling the server and turning the data it returns into a table. I
I am trying to write a function that connects to a database and returns
I'm trying to build up a page that will show a progress bar until
OK, I'm actually calling some java middleware that returns a captcha image. The captcha
I've created a GreaseMonkey script based on an in-page script that I'd like to
I need a way of calling a web page from inside my .net appliction.
Would there be any problems calling an HTTPS page (e.g. a credit card authorisation
I need to start a Unix process by calling a PHP-page through the web.
I have a number of iframes calling a function in my main page. Is

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.