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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:08:26+00:00 2026-06-05T01:08:26+00:00

I am new to ajax and need some help in understanding how javascript runs

  • 0

I am new to ajax and need some help in understanding how javascript runs in a browser. The problem I am trying to solve is to intercept ajax responses using a second javascript(injected into this page).

When the user first loads the page, I modify the server response(through proxy) by appending my own javascript. Later during normal operation user tries to get some content through this page, I want to be able to intercept this response when it contains specific http headers or content using the injected javascript and show a popup.

Is this even feasible? I checked other related questions and found that this can be done using browser extensions(content scripts etc) but I would like to know if this possible using javascript injection on the page itself.

  • 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-05T01:08:28+00:00Added an answer on June 5, 2026 at 1:08 am

    How do you intend to intercept the AJAX response? The only way I see that’s possible using JavaScript is if you have access to the original XMLHttpRequest object. Consider:

    var request = new XMLHttpRequest;
    request.onreadystatechange = handler;
    request.open("GET", "/somefile.php", true);
    request.send();
    
    function handler() {
        if (request.readyState == 4 && request.status == 200) {
            // do something
        }
    }
    

    Now to intercept this AJAX response you would need to override the request.onreadystatechange event handler and to do so you would need access to the request object.

    Since you are trying to intercept the response using an injected script your script will only have access to global variables, which means that you’ll only be able to intercept the AJAX response if the request object is a global variable.

    Even then you can never be sure that the script which you inject will be executed before, after or during the AJAX request. The best you can do is check the readyState of the request and simply give up if it’s too late.

    If you’re trying to launch an XSS attack intercepting AJAX responses are definitely not viable. Cheers.

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

Sidebar

Related Questions

I need some help in using Google AJAX Feed API. As we know by
Hey there, new to AJAX, JS.. Im trying to add to a Javascript/Ajax search
I need help understanding the best way to manipulate a JavaScript data structure (if
I'm just starting out with the whole ajax thing and I need some help.
I need some help with my web service and json call.. stuck trying to
I need some help here.. Im trying to save a canvas image after drawing..
I am a total noob to jQuery and Javascript.. need some help. I have
i am new to AJAX i am trying to update a Repeater Control When
i am new to ajax and read some tuts to make a lil script
I need some advice on how I am using JQuery, JSP and Lucene 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.