Click here to Skip to main content
15,883,127 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm using a WebBrowser control in my app to load a page that updates its content dynamically via Ajax. I need to access the updated content to do some processing, but since the calls are made with Ajax the page doesn't get refreshed and thus the DocumentComplete event doesn't fire. 
Is there a way to get notified when a call is made using the XMLHttpRequest object? Some event fires maybe?
Any help will be appreciated, 


What I have tried:

I don't try any thing in this matter
Posted
Updated 2-Jun-19 16:45pm

1 solution

XMLHttpRequest has a property onReadyStateChange.

You can assign a function to this such as:

JavaScript
var xmlHttpReq;  // You need to fill-in details for creation of this
                 // request object and triggering the request etc.

function respAjax() {
  if (xmlHttpReq.readState == 4) {
    // Request has finished and response is ready.
    // Do whatever you want here..
  }
}

xmlHttpReq.onReadStateChange = respAjax;


Chapter 11 of Sams_Teach_Yourself_Ajax.. provides much more info, and if you're doing Ajax this is a superb book to read.
 
Share this answer
 
Comments
multi 4u 13-Apr-17 10:50am    
can you explain a little more.Only tell me the process.Thanx
Nick_3141592654 13-Apr-17 11:08am    
I think that you need to share more about your current approach first because you've not spelt-out exactly how you're doing the Ajax. I've gone back to the basics which is a raw XMLHttpRequest - this is the fundamental way that Ajax is done, however there are lots of implementations that wrap such a request inside some library, or bundled with a control.

Try looking again at the API for the WebBrowserControl that you mention (and please tell us exactly what it is), I'd be surprised if it doesn't make the onReadyStateChange event available to you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900