Q:

XMLHttpRequest to open PDF in browser

I want to do XMLHttpRequest and then open a PDF in the Browser by sending the filename by POST method.
   xmlhttp.open("POST","pdf.php",true); //CHANGE
   xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
   xmlhttp.send("file="+input);

Is that possible or XMLHttpRequest is just for HTML?

A:

It is not possible to do via XMLHttpRequest if the URL you are querying actually returns the PDF data.
Why? Because the response is an HTTP response which contains raw PDF data. There is no JavaScript ability to replace the current document's DOM contents with a rendering of a  PDF contained in that data, even though you DO have access to the data via  responseText` attribute (also see http://www.w3.org/TR/XMLHttpRequest/#the-responsetext-attribute).
What you CAN do is to generate a PDF file into a temporary file accessible via a URL from your web server, and then have the script send back the URL for accessing that file.
When your response handler processes the URL, it can either:

Re-load the current page by changing window.location.href = new_pdf_url
Load it in an <iframe> inside the current document by changing iframe's src attribute
Open it in a separate window by window.open(new_pdf_url, XXX)
Please note that you STILL need a URL to a temp file location to open a new window

