Pascal
Pascal

Reputation: 2984

Detect when AJAX changes HTML in a DIV in WebBrowser

After I load a page through a WebBrowser, and I click a link that fires an AJAX script, I need to detect when the AJAX java script finishes loading HTML changes into a div. Since no DocumentCompleted event is fired when the AJAX script is run, I don't know when it finish running. Is there a way I can attach an event to be raised after I know 100% that the javascript finished changing the div?
The project is in C#.
Thanks

Upvotes: 2

Views: 2654

Answers (2)

Brother Erryn
Brother Erryn

Reputation: 841

I did something similar recently (using jQuery):

$('#mydiv').change(function(){
        // do stuff
    }
);

Granted, I also use jQuery to set the HTML of that div. I suppose one non-jQuery approach for you could be to set HTML through your own function, which in turn can fire an onchange event.

@New in town: From my experience that is not correct. I use this on multiple DIVs that never get focus in the first place, and it works well and consistently. The normal behavior is as you describe, and normally only applies to the INPUT and SELECT elements, but this is not the case with jQuery.

Upvotes: 1

Aaron Digulla
Aaron Digulla

Reputation: 328800

There is no event. You must patch the JavaScript callback that the browser runs when the reply for the AJAX request comes in. This will contains code like "div.innerHTML = ...". Just put your code below that.

Upvotes: 0

Related Questions