html - ajax issue to display the content of a simply doc -
I really want to do something with Ajax. My Mac has a folder with 2 documents: index.html and text.txt.
index.html:
& lt; P & gt; & Lt; Input type = "button" onclick = "loadDoc ()" value = "click" /> & Lt; / P & gt; & Lt; P id = "fileContent" & gt; & Lt; / P & gt; & Lt; Script & gt; Function loadDoc () {var xhr = new XMLHttpRequest (); Xhr.open ('gET', 'text.txt', true); Xhr.onreadystatechange = function () {document.getElementById ('File Content'). InnerHTML = xhr.responseText; } Xhr.send (null); } & Lt; / Script & gt;
text.txt:
Hello When the user clicks the click button, then I want to click on the 'Hello' button on the contents of text.txt.
Does it work locally with my Mac? Do you know?
Thank you!
Ajax requests can not be made on file: /// this one Security restriction is. What do you have right but need service through http: //
Comments
Post a Comment