I am building a website that communicates via javascript with a webservice that accepts posted json requests. I Post these requests using XMLHttpRequest. In some cases the service returns a download response:
Example:
Content-Disposition: attachment; filename="somefile.txt"
Content-Type: application/force-download
Content-Length: 3
123
if document.location is pointed to an URL that serves a response like the one above, the browser will automatically prompt the user with a file download dialog.
My question is: Can I achieve the same effect with XMLHttpResponse objects somehow? is there an Iframe trick or something? Unfortunately there is no target member on XMLHttpRequest objects like there is on html forms, cause if I could just redirect the full response (with headers) to a new page or hidden iframe the problem would be solved, I guess.