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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:50:01+00:00 2026-05-23T19:50:01+00:00

Hello I have a jQuery function that will send to a php file some

  • 0

Hello I have a jQuery function that will send to a php file some info. The PHP file will do the stuff it has supposed to do and will generate some HTML code. I am fine until here.

The problem is that I have then to take the HTML results generated by this PHP file and write them in the page where the Ajax call has been created, simply by appending it after a DIV or inside a DIV or whatever.

This is the jQuery function I have so far:

$(document).ready(function() {
var idGenre = $("#txtGenre option:selected").val();
var html = $.ajax({
             type: "POST",
             url: "GetSubGenreData.php",
             data: "id=" + idGenre,
             async: false
             }).responseText;

});

The DIV that must be updated with the HTML results taken from the PHP file GetSubGenreData.php is:

<div id ="divSubGenre"></div>

Now lets say the PHP file will return a select box, something like this:

<select>
<option>1</option>
<option>2</option>
<option>3</option>
etc...
</select>

This select box must be appended just after the DIV <div id ="divSubGenre"></div> or by simply replacing this DIV with the returned Select Box. Nothing impossible for a good jQuery developer. But I am not.

I just need the function to write the HTML results from the PHP file in the right DIV.

Thanks!!

  • 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-23T19:50:03+00:00Added an answer on May 23, 2026 at 7:50 pm

    in your success callback

    success:function(html){
    
    $("#divSubGenre").append(html);
    }
    

    if you want to replace the container div with the ajax response

    success:function(html){
    
    $("#divSubGenre").replaceWith(html);
    }
    

    if the div to which you are appending the results is not empty then to insert after the div use after

    success:function(html){
    $("#divSubGenre").after(html);
    }
    

    so your final code may look like this

    $(document).ready(function() {
    var idGenre = $("#txtGenre option:selected").val();
    var html = $.ajax({
                 type: "POST",
                 url: "GetSubGenreData.php",
                 data: {id:idGenre},
                 async: false,
                 success:function(html){
                   $("#divSubGenre").append(html);
                 }
                });
    
    });
    

    jquery ajax

    jquery replaceWith

    jquery append

    jquery after

    update

    $("#txtGenre").change(function(){
    //get the update value here
    var idGenre = $("#txtGenre option:selected").val();
      $.ajax({
                 type: "POST",
                 url: "GetSubGenreData.php",
                 data: {id:idGenre},
                 async: false,
                 success:function(html){
                   $("#divSubGenre").html(html);
                 }
                });
    
    });
    

    jquery change

    yet another update
    about the comment to show the result on page load, if i have understood the scenario well you can have two divs on the page like

    <div id="divSubGenre"></div>
    <div id="divonLoad"></div>
    

    on the page load do the ajax call and append the result to #divonLoad and in the success callback of your ajax call that is inside the change event handler do this

    success:function(html){
    $("#divonLoad").fadeOut("slow").remove(); removes the div that was holding the result on page load
    $("#divSubGenre").html(html);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have this snippet of jQuery code jQuery(document).ready(function($) { $.get(<?echo $site['url'];?>modules/tuitting/tuitting_core/classes/count.php, function (data)
I have a function that returns a string of HTML code for a jQuery
I have a linux webserver that has /var/www configured in the Apache2.conf file as
Hello I have a jquery function called create time box This creates a textbox
Imagine I have the following: inFile = /adda/adas/sdas/hello.txt # that instruction give me hello.txt
I have a file called hellowf.cs class MyFirstApp { static void Main() { System.Windows.Forms.MessageBox.Show(Hello,
I have a library I created, File mylib.c: #include <mylib.h> int testlib() { printf("Hello,
I have a jQuery script that fades in and fades out between containers inside
I am looking for a simple script that I can use to send some
http://jqueryui.com/demos/accordion/#event-changestart I'm trying to have an JQuery ajax request get some data and populate

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.