javascript - Cant execute an html file that includes AJAX -
i'm new @ html , want run code includes script demonstrates ajax.this file saved html file. when try run in localhost script doesnt execute. dont understand why. can explain this?
<!doctype html> <html> <head> </head> <body> <p id="demo">let ajax change text.</p> <button type="button" onclick="loaddoc()">change content</button> <script type="text/javascript"> function loaddoc() { var xhttp; if (window.xmlhttprequest) { // code modern browsers xhttp = new xmlhttprequest(); } else { // code ie6, ie5 xhttp = new activexobject("microsoft.xmlhttp"); } xhttp.onreadystatechange = function() { if (xhttp.readystate == 4 && xhttp.status == 200) { document.getelementbyid("demo").innerhtml = xhttp.responsetext; } }; xhttp.open("get", "ajax_info.txt", true); xhttp.send(); } </script> </body> </html>
thanks in advance.
Comments
Post a Comment