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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:48:44+00:00 2026-05-27T17:48:44+00:00

I want to call some javascript functions after all ajax calls. I know how

  • 0

I want to call some javascript functions after all ajax calls. I know how to call the functions inside each individual ajax call as shown below:

function xyz()
{

if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
   }
 else
   {// code for IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
 xmlhttp.onreadystatechange=function()
   {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
     document.getElementById("links").innerHTML=xmlhttp.responseText;

     *****javacsript would go here*****
   }

 xmlhttp.open("GET","xhr_php/site_links.php",true);
 xmlhttp.send();
 }
 }

so again, i know how to call it after or inside each ajax call as shown above. But i am wondering if there is a function that would call the functions after all/any ajax calls. This way i don’t have to write the javascript inside each ajax call. I think it has something to do with an endrequesthandler but not sure how that is written in php/javascript. I found some thing online as it pertains to asp.net but im using php.

Id also like a way to call functions at the start of the ajax call or before the ajax call.

This way i can start and stop functions during ajax calls without having to write this inside each call.

Thank you for your help.

  • 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-27T17:48:45+00:00Added an answer on May 27, 2026 at 5:48 pm

    You can have it take a callback function:

    function xyz(callback) {
        var xmlhttp;
        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else { // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                callback(this);
            }
    
        }
        xmlhttp.open("GET", "xhr_php/site_links.php", true);
        xmlhttp.send();
    }
    

    Then:

    xyz( function( xhr ) {
    
        alert( xhr.responseText );
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I want to call a javascript function after some code has been run
I want to write some javascript and have it call into the DOM for
I want to create some kind of AJAX script or call that continuously will
I render some new content with .html() after ajax call into my site. $.getJSON(scriptURL,
I know that ajax calls are asynchronous but there are situations like some synchronous
I'm struggling with trying to modify some Javascript code. I know what I want
I want to call some RESTful web services from a J2ME client running on
I want to have an executable file that will call some other programs. The
I want to call an ASHX file and pass some query string variables from
I want to call a url with passing some parameter and i want to

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.