0

I currently load a html page into a <DIV> in my page. using this code

$.ajax({
        url: 'myApi.php?user=' + user + '&url='+ URL2add, 
        success: function(html) {                    
            var newHTML = "<object id='webloader' data='" + html + "'></object>";
            $("#exweb").fadeOut(500, function () {
                $("#exweb").html(newHTML).fadeIn(5000, function() {
                    alert("done");
                });
            });
        }
});

So i want to do a check or preferably get a alert once that page loaded changes. which is in the data tag that comes from the html coining back from the ajax call.

I have tried document.getElementsByTagName

I know there has to be a way to get the new data info in that object .

i would prefer an alert each time the page changes from what comes back from the ajax call

i have updated the code like this...

 $(document).on('contentchanged', '#exweb', function() {

        alert('WOO?');
    });

     $.ajax({
                url: 'Api.php?user=' + user + '&url='+ URL2add, 
                success: function(html) {                    
                var newHTML = "<object id='webloader' data='" + html + "'></object>";
                $("#exweb").fadeOut(50, function () {
                    $("#exweb").html(newHTML).fadeIn(50, function() {
                    $('#exweb').trigger('contentchanged');

                            });
                    });
                }     
                });

But this is only working on initial change

i need to know when that page changes again.. say if someone clicks on a link that will change the page in DIV or if its a redirect page.

i want to know whenever that page changes to something after i loaded it from my ajax call

should it not be as easy as getting the information between data=""

<object id="webloader" data="http://google.com"></object>

and how do i get back that info? i have tried document.getElementsByTagName

Dynamite Media
  • 159
  • 2
  • 10

3 Answers3

0

you can do something like this after ajax.

$.ajax({...}).done(function() {
alert('page loaded');
});
dotsinspace
  • 661
  • 7
  • 21
0

I think you could try this $("div").load("your_url.php?parameters"); the page you want to load could have the following <body onload="alert('Page Loaded')"> Update:- if you dont have the access of the webpage then use this $("div").load("your_url.php?parameters",function(){alert("Page loaded")});

0
$.ajax({/* your AJAX */}).done(function() {
  alert(/*your text*/"page loaded!");
});
Radi Cho
  • 680
  • 7
  • 21
  • While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Adam Apr 16 '17 at 23:11