Loading a html page with pure Javascript using AJAX -
there main page , there links on page. when individual links clicked, supposed load contents link loads inside div tag of main page.
example: mainpage.htm
<html> ... <body> ... <div id="maincontent"> </div> ... <a href='link1.htm'>link 1 </a> ... </html>
link1.htm
<script src="main.js">... <div> other contents here </div>
when user clicks on link 1, browser doesn't go page, instead ajax used fetch linked document , load inside #maincontent
.
but, problem linked page has table , there table manipulation codes needed run when first loads. in fact linked document has link separate script , functions supposed run on window.onload
.
when load linked document using ajax using following approach:
maincontent.innerhtml = xhr.responsetext;
this not helping run window.onload
codes on linked document.
are there solutions or workaround type of problem?
just side note: using javascript no other apis angular or jquery or similar.
something wrong approach. main problem here context of new content getting via ajax not gonna executed because window.onload done.
when refer "table manipulation codes" assume there couple of javascript functions needs executed after content appended in html, can try on here moving "manipulations" separate js file , include in index.html , execute proper functions in success callback after getting content via ajax.
i think should more accurate approach.
Comments
Post a Comment