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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:26:09+00:00 2026-05-28T00:26:09+00:00

After spending several hours, I’m stumped. I can’t get what should be a simple

  • 0

After spending several hours, I’m stumped. I can’t get what should be a simple jQuery function to work as intended. This is like my second try at jQuery so I’m a bit of a noob, but I’ve spent time on reading multiple tutorials, looked at other similar questions here etc, but I just can’t get it to work.

I’ve got a menu which I would like to populate with data provided from a simple Ajax call. Debugging, I can see that everything fires correctly, except for one thing; it won’t populate my newly created div with the returned data. Here’s the code:

$(document).ready(function() {
$("#parent").on({ // Tested with .live as well, same result =/
    click: function() {
        //$(this).empty();
        $(this).append('<div id="#data-child"></div>'); // Is created
        getAjaxFunction('child');
    },
    mouseenter: function(){
        //$(this).empty();
        $(this).append('<div id="#data-child"></div>'); // Is created
        getAjaxFunction('child');
    },
    mouseleave: function(){
        $(this).remove('#data-child'); // Won't remove
    }
})
});

As you may suspect, the .remove won’t remove the #mydiv either. The getAjaxFunction looks like this, if it may be of value:

function getAjaxFunction( page ) {
$.ajax({
    type: "GET",
    url: "include/getdata.php",
    data: { section: page },
    datatype: "html",
    beforeSend:function(){
        // this is where we append a loading image, but it won't show...
        $('#data-'+page).append('<div class="loading"><img src="/images/pb-loader.gif" alt="Loading..." /></div>');
    },
    success: function(data) { // data is returned correctly
        $('#data-'+page).empty();
        $('#data-'+page).append (data); //won't append the data. tested with .html instead as well, without luck =/
    },
    error:function(){
        $('#data-'+page).append('<p class="error"><strong>Oops!</strong> Something went wrong. Please try again later...</p>');
    }
});}

Would be very appreciative to any answers to this, thanks!
I’m suspecting I’m overdoing things but this is what I ended up with when the simple hover functionality wouldn’t work for me xD

  • 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-28T00:26:10+00:00Added an answer on May 28, 2026 at 12:26 am

    I would have written this as a comment to your question but my rep isn’t there yet. Since nobody has answered your question I think that this is probably better than nothing.

    What happens if you do this?

    success: function(data) { // data is returned correctly
        $('#data-'+page).empty();
        $('#data-'+page).append (data); //won't append the data. tested with .html instead as well, without luck =/
        console.log($('#data-'+page));
        console.log(data);
    },
    

    Do you get the div that should be updated and the correct data?

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

Sidebar

Related Questions

After spending SEVERAL frustrated hours on this I am asking for your help. I
EDIT: After spending several hours researching this, I don't think I'm going to find
I'm really frustrated after spending like three hours googling around to solve this problem!!
After spending many hours poking around trying to get an ASP .NET AJAX proxy
After spending three weeks learning Objective-C and Cocoa programming for my work, I've been
Originally, I was having some issues getting this code to function, but after a
After spending a good 3 to 4 hours on google trying to find any
After spending some hours with the Ruby Debugger I finally learned that I need
So, after spending a couple of hours of manually configuring autotools, I finally managed
After spending the best part of 3 hours getting nowhere, i thought i would

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.