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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:25:14+00:00 2026-05-30T15:25:14+00:00

On mouseenter I make an AJAX request to get some dynamic text based on

  • 0

On mouseenter I make an AJAX request to get some dynamic text based on the title attribute of the hovered href and show it in another div.

It’s a list of links and when I hover over them very fast, all ajax requests are finished and all text is shown one after another very quick until the current text shows up.

How can I stop previously called requests and prevent every text to show up in my div?

This is what I’ve got so far:

$('.link').mouseenter(function(e) {

var text = $(this).attr('title');

$('#showtext').show().html('Loading...');

    $.ajax({
    url: '/show.php?text=' + text,
    cache: false,
    success: function(data) {
        $('#showtext').html(data);
    },
    error: function(xhr, ajaxOptions, thrownError){
        $('#showtext').html('Error.');
    }
    });

});

$('.link').mouseleave(function() {
    $('#showtext').hide();
}

I tried to use .stopPropagation() and .preventDefault() on mouseenter and mouseleave and also .abort()

Thanks in advance!

  • 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-30T15:25:16+00:00Added an answer on May 30, 2026 at 3:25 pm

    Alex’s solution is sufficient, but does not abort slow requests. Also, I avoid plugins for trivial things like timeout. jsfiddle

    (function($) {
        var request;
        $('.link').bind('updatetext', function() {
            var text = $(this).attr('title');
            $('#showtext').show().html('Loading...');
            request = $.ajax({
                url: '/show.php?text=' + text
                cache: false,
                dataType: 'html',
                success: function(data) {
                    $('#showtext').html(data);
                },
                error: function(xhr, ajaxOptions, thrownError) {
                    $('#showtext').html('Error finding ' + text);
                }
            });
        });
        var timeout;
        $('.link').mouseenter(function(e) {
            var self = this;
            clearTimeout(timeout);
            timeout = setTimeout(function() {
                $(self).trigger('updatetext')
            }, 500);
        });
        $('.link').mouseleave(function() {
            if (request) {
                request.abort();
                request = null;
            }
            $('#showtext').hide();
        });
    })(jQuery);​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can get MouseEnter , MouseLeave , and Click events to fire, but not
hey, Im trying to make a call a jquery function and pass some args
I have the following code $(#nav-mail).mouseenter(function(){ $(#dropdown_mail).show(); }); $(#dropdown_mail,#nav-mail).mouseleave(function(){ $(#dropdown_mail).hide(); }); and I am
I want to make bubble of text appear when the mouse is over a
I'm trying to make a simple pop-up <div> that's designed to show mouse coordinates
I am currently trying to make some jQuery hover effects render correctly in all
If I want to mouseenter a div, an element will show, then when mouseleave,
I need to tie a WPF-Command to the MouseEnter event of a Stackpanel. How
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
I have: $('.p_m').mouseenter(function () { $(this).animate({ marginTop: '10px', marginLeft: '10px', height: '150px', width: '150px'

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.