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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:48:19+00:00 2026-06-16T06:48:19+00:00

In the console print aaa, but I can not make it print bbb by

  • 0

In the console print “aaa”, but I can not make it print “bbb” by clicking on click $(“#test”).

That mistake I’m making? Any suggestions are welcome. Thank you.
Sorry for my bad English.

main.js:

$("#load").click(function () {
    $.post("second.php",function(data){
        $('#result').html(data);
    });
    return false;
});

main.html:

...
<div id="result"></div>
...

second.php return:

<script>
$(document).ready(function() {
        try
        {
            console.log("aaa");
            $("#test").click(function () {
                console.log("bbb");
                return false;
            });
        }catch(e){}
    });
</script>

<div>hello</div>
<a id="test" href="#">Test</a>
  • 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-16T06:48:20+00:00Added an answer on June 16, 2026 at 6:48 am

    The problem is that document.ready has already occured in the main page. This means that any code in your AJAX will fire immediately even when wrapped in document.ready. If the code precedes the html it referrs to, it will fire before the html exists

    If you place your code after the same html it will work.

    The alternative is to use on() to delegate event handlers to future elements that don’t exist when page loads. Uou can use on() in the main page and run it when main page loads

    Delegation example

    $(document).on('click','#test', function(){
    
       console.log('bbbb');
       return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to print my whole file compilation options on make in my console
I need to write a small console app (patch) that turns off the print
I am trying to get the function feedAmount to print to the console but
I have an Array , if I print that in console it shows Price
Lets say I want a mouse click event listener to trace (console print) the
How can I send trace messages to the console (like print ) when I'm
I would like to write a Console class that can output coloured text to
When I try to print an integer value to the console that is retrieved
In Perl print a x 3; # aaa In C# Console.WriteLine( ??? )
i want to read characters from the console and print them one after another

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.