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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:21:58+00:00 2026-05-27T01:21:58+00:00

I did a quick Google on the title and got pummelled with all this

  • 0

I did a quick Google on the title and got pummelled with all this code that I didn’t understand a word of.

I’ve been JavaScript programming for a couple of years now and am comfortable with most concepts. Except event handling. It scares me!

The problem

I have a div which I’ve wrote a script for, that scrolls the div vertically purely based on mouse position.

I get the height of the container, and height of the inner container that will "overflow".

Divide them to get a "differential" and then multiple the mouse position by this differential to get the div to scroll depending on the mouse position.

It gives me a nice clean scroll!

(If anybody wants more info on this just ask)

My problem is. The contents of this div are generated by ajax.

Therefore when the code to calculate the height of both inner and outer divs is ran, it gives the incorrect height, as they haven’t been populated by data yet.

So I need to fire an function WHEN the ajax has copied the data to the innerHTML to call the mousescroll function.

Extra

Issues: I have two ajax calls that populate the scrollable div. and sometimes one gets fetched before the other and vice versa. So I need the mousescroll function to fire WHEN and only WHEN both of the ajax calls have completely entered all the data into the html that they can!

I was thinking about just adding a setTimeout but… I don’t like forcing my scripts to wait!

  • 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-27T01:21:59+00:00Added an answer on May 27, 2026 at 1:21 am

    I’m not 100% clear on where the problem is. You write: “I need to fire an function WHEN the ajax has copied the data to the innerHTML to call the mousescroll function.” — do you need help with that part of it? If you’re using jQuery, then you just call the mousescroll function inside of the success callback function of $.ajax.

    As you point out, however, this is complicated by the other issue you bring up: there are actually two Ajax calls and you want them both to complete before calling the mousescroll function. To solve this, simply create a variable that is equal to zero, and then increment it within both success callbacks. Those callbacks would also check the value of the variable, and if it equals 1 (meaning that an Ajax call has already completed), call the mousescroll function.

    pseudo code:

    var numOfAjaxCalls = 0;
    
    $.ajax({
        ...
        success: function(){
            if(numOfAjaxCalls = 1){
                mousescroll();
            }else{
                numOfAjaxCalls++;
            }
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did a quick search but could not find anything about this. I guess all
I did a quick search on SO for this and didn't come up with
I did a quick search and got this link From StackOverflow I get this
I did a quick google on implementing clone() in Java and found: http://www.javapractices.com/topic/TopicAction.do?Id=71 It
I did a quick search, but couldn't find a specific solution to this (I'm
If this question seems common to you, I apologise, I did a quick search
So a search on google didn't turn up anything and neither did StackOverflow so
Just got a car with the Microsoft sync system in it. Did a quick
I did a quick search and could not find anything on this topic. I
After experiencing it myself, I did a quick search and found that SelectionChanged will

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.