user ajax to get data without "onClick function" in javaScript -


i've been searching example of getting data using ajax without onclick function of example found within onclick funtion.
here html data using onclick funtion

<!doctype html> <html lang="en"> <head>    <meta charset="utf-8" />    <title>new document</title>     <script type = 'text/javascript' src='js/jquery-2.2.0.js'></script>  <script type ='text/javascript' src='js/testscript.js'></script>  <?php include_once("database_conn_getoffers.php"); ?> </head> <body>    content goes here    <aside id="offer" onclick ="loaddoc('getdata.php',myfunction)">         &nbsp; click here         </aside> </body> 

here script

function loaddoc(url, cfunction) {   var xhttp;   xhttp=new xmlhttprequest();   xhttp.onreadystatechange = function() {     if (this.readystate == 4 && this.status == 200) {       cfunction(this);     }   };   xhttp.open("get", url, true);   xhttp.send(); } function myfunction(xhttp) {   document.getelementbyid("offer").innerhtml =   xhttp.responsetext; } 

now, wanted data without onclick function.
want data show once open html.
can provide me link or gv me example ??

body onload doesnt required. can directly use window onload function in js

js

window.onload = function() {   loaddoc('getdata.php',myfunction) }; 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -