why can't i change this div's innetHTML with ajax? -


Just started learning AJAX today and fell on the first stage, the worst part is, what I really can not find With the code, can you see it?

The internal HTML of the device should be converted into a response. Text within the data.txt. The text inside of this file is "Hey man" (cuz no hello world does not like)

   & Lt; / Head & gt; & Lt; Body & gt; & Lt; div id = "hehe" & gt; Ha ... We are here, this will be an Ajax performance! & Lt; / Div & gt; & Lt; / Body & gt; & Lt; script src = "script.js" & gt; & Lt; / Script & gt; & Lt; / Html & gt;   

javascript

  var request = new XMLHttpRequest (); Request.open ('receive', 'data.txt'); Document.onreadystatechange = function () {if ((this.readyState === 4) & amp; (this.status === 200)) {document.getElementById ('hehe'). InnerHTML = request.responseText; }}; Sent request ();   

Thanks in advance!

use the request Onreadystatechange not document.onreadystatechange .

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -