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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:16:27+00:00 2026-06-11T03:16:27+00:00

In the HTML, a dropdown with the ID=project_pick will fire a change event, sending

  • 0

In the HTML, a dropdown with the ID=”project_pick” will fire a change event, sending the selected value to the getallreports.php file. This works. The PHP file does a MySQL lookup and returns values inside some HTML. This also works, and looks great on the page. Here below is the jQuery/ajax code that sends the selected item to the PHP file:

$('#project_pick').change(function(e) {
    $.ajax({
        type: "POST",
        url: "getallreports.php",
        data: "project_id=" + $(this).val(),
        success:function(data){
            $('#reportstable').html(data);
        }
    });
});

The returned data appears inside the specified div, and includes anchor tags with specific IDs that should allow other JQuery events to happen. Snippet of returned HTML:

<table><tr>
    <td>Report 1</td><td><a href="#" id="change_1">click to change</a></td>
    <td>Report 2</td><td><a href="#" id="change_2">click to change</a></td>
</tr></table>

The jQuery code to trigger on the above click event is:

$('#change_1').click(function() {
    alert('Change Report One was clicked');
});

However, clicking the above anchor tag does nothing. Also, the returned HTML does not even appear in the source — although it shows on the screen and in firebug.

What am I missing? How can I get that click event to fire?

EDIT:

I’ve been reminded about the .on(‘click’, etc) event (thanks Michael and Zirkms), but when I attempted to add it to my code the dropdown’s .change event stopped firing. Perhaps the below code needs a facelift?

$('#project_pick').on(change(function(e) {
    $.ajax({
        type: "POST",
        url: "getallreports.php",
        data: "project_id=" + $(this).val(),
        success:function(data){
            $('#reportstable').html(data);
        }
    });
});
  • 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-06-11T03:16:29+00:00Added an answer on June 11, 2026 at 3:16 am

    On the moment of $('#test').click() code execution #test didn’t exist in the DOM, so you didn’t bind that handler to somewhere.

    Use

    $(document).on('click', '#test', function() { ... });
    

    instead

    Or (better) if you have a particular node where you insert the retrieved html – use some particular selector rather than $(document) like

    $('#reportstable').on(...)
    

    does not even appear in the source

    In the “view source” browsers usually show the response from the server as it was retrieved on request, without reflecting JS DOM modifications.

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

Sidebar

Related Questions

I have this HTML dropdown: <form> <input type=text id=realtxt onkeyup=searchSel()> <select id=select name=basic-combo size=1>
I've been attempting to associate a PHP script with an HTML dropdown menu. What
I have multiple dropdown list: @Html.DropDownListFor(x => x.HaveColoSpace.SelectedOptions, new SelectList(Model.HaveColoSpace.Options, Value, Text), new {
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
if i have a dropdown with the following html: <select id=myDropdown name=myDropdown> <option value=6>Six</option>
On change of the dropdown list, A php function should called. Inside the PHP
My problem comes from HTML dropdown select not able to preserve multiple consecutive whitespaces
I am just trying to populate a html.dropdown list using mvc2 in VS2008. But
I have an editor template with a dropdown: @Html.DropDownListFor(m => m.AdmissionState, new List<SelectListItem>() {
I'm building a mobile website. I use regular html for the dropdown like below.

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.