Ajax Example
Load Text file data using ajax
Simple Ajax example to load the content of the text file without refreshing the whole web page.
Load test file example
<!DOCTYPE html> <html> <head> <script> function Url() { var u; if(window.XMLHttpRequest) { u=new XMLHttpRequest(); } else { u=new ActiveXObject("Microsoft.XMLHTTP") } u.onreadystatechange=function () { if(u.readyState==4 && u.status==200) { document.getElementById("kk").innerHTML=u.responseText; } } u.open("GET","test.txt",true); u.send(); } </script> </head> <body> <h1>Load The txt file using Ajax </h1> <button type="button" onclick="Url()">Load</button> <hr> <div id="kk"></div> </body> </html>
- Example
- Run
Text file
//test.txt This is the text file Load via Ajax