-1

As I've successfully open a xy.php page in div id="portfolio" of the working abc.php page without redirection. But the problem arose is that I think it is a synchronized call that is why when the xy.php page open in a div id="portfolio" than its <body onload=""> onload function does not call because this xy.php page is opened using synchronised method not redirect. So, On Synchronised call how to run the functions which is present inside onload="". Any Suggestions ? ? ?

Here is my working JS Fiddle

I'm calling the next page on `

                <li><a data-async-load="xy.php"></a></li>` tag
Naveed Cheema
  • 77
  • 3
  • 13
  • 1
    Inline script is not called using .load - you need to not have onload event handlers on tags and instead extract them and call them in the parent document - https://stackoverflow.com/questions/4619668/executing-script-inside-div-retrieved-by-ajax – mplungjan Nov 21 '17 at 10:23
  • As mplungjan said, you can't have embedded inline scripts auto execute this way. You should instead replicate their behaviour in the success option of the .load() method you're using to load the page. – delinear Nov 21 '17 at 10:27
  • I did not get it. I just want to run `xy.php` functions that is it. How do I get this approach ? any example – Naveed Cheema Nov 21 '17 at 10:28
  • Any example @delinear – Naveed Cheema Nov 21 '17 at 10:28
  • I just want to call the functions on onload method when the page is open – Naveed Cheema Nov 21 '17 at 10:33
  • @mplungjan so where should i've to do change ?? ? ? I'm searching but didn't get anything – Naveed Cheema Nov 21 '17 at 12:04
  • if you do not want to move the JS code from xy.php as you should, then you need to load the page, find the script tags that contains the function called in the onload and eval it – mplungjan Nov 21 '17 at 12:07

1 Answers1

0

Ok I Did it!!!!
The functions <body onload="myfuna();myfunb();"> which are called on loading or redirecting or refereshing the page is know called by using JQuery and it works when you are loading your page by synchronisation data-async-load. Here is the code

 <script>
 $(document).ready(function () {
 myfuna();
 myfunb();
 });
 if (document.readyState == 'complete')
 doOnLoad();

 $(window).bind("load", doOnLoad); 

 </script>
Naveed Cheema
  • 77
  • 3
  • 13