Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following works fine for me in Firefox and IE8:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; // MAYBE FORGOT THIS PART? var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { document.write(xmlhttp.responseText); } } // THIS PART IS EXACTLY LIKE YOURS var params = "type=search" + "&amp;content="+encodeURIComponent(document.getElementsByTagName("body")[0].innerHTML); xmlhttp.open("POST", "/service/p.aspx", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.send(params); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Perhaps you just forgot to declare <code>xmlhttp</code> and add a listener for the asynchronous status callback?</p> <hr> <p>Also, see <a href="https://stackoverflow.com/questions/415160/best-method-of-instantiating-an-xmlhttprequest-object">this SO question</a> for more information about getting an <code>XMLHttpRequest</code> object in a cross-browser fashion.</p> <hr> <p>Here is what is being sent in the POST request via FireBug in Firefox:</p> <pre><code>type=search&amp;content=%0A%20%20%20%20%20%20%20%20%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0A%2F%2F%20MAYBE%20FORGOT%20THIS%20PART%3F%0Avar%20xmlhttp%20%3D%20new%20XMLHttpRequest()%3B%0Axmlhttp.onreadystatechange%3Dfunction()%0A%7B%0A%20%20%20%20if%20(xmlhttp.readyState%3D%3D4)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20document.write(xmlhttp.responseText)%3B%0A%20%20%20%20%7D%0A%7D%0A%0A%2F%2F%20THIS%20PART%20IS%20EXACTLY%20LIKE%20YOURS%0Avar%20params%20%3D%20%22type%3Dsearch%22%20%2B%20%22%26content%3D%22%2BencodeURIComponent(document.getElementsByTagName(%22body%22)%5B0%5D.innerHTML)%3B%0Axmlhttp.open(%22POST%22%2C%20%22%2Fservice%2Fp.aspx%22%2C%20true)%3B%0Axmlhttp.setRequestHeader(%22Content-type%22%2C%20%22application%2Fx-www-form-urlencoded%22)%3B%0Axmlhttp.setRequestHeader(%22Content-length%22%2C%20params.length)%3B%20%0Axmlhttp.send(params)%3B%0A%20%20%20%20%20%20%20%20%3C%2Fscript%3E </code></pre> <p>So you have <code>type</code> which equals <code>search</code>, and <code>content</code>, which is the HTTP-encoded <code>body</code> of the HTML above, exactly as programmed. So it seems to be working as intended...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload