| | |
Interpret HTTP (Content-Disposition) headers from an XMLHTTP object?
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I'm trying to implement an AJAX solution for exporting tabular data on a page in certain formats, and i've determined that the best way to do this (for my purposes) is to grab the innerHTML of a table, send it off to a server-side script for processing into alternate formats, and then returning the response with appropriate Content-Type and Content-Disposition headers. The issue I'm having is how exactly to get the browser to interpret said headers.
For example, I send the table's innerHTML in a POST request to a server-side script (via an XMLHTTP object):
If someone directly requests the server-side script (ie: through a form), it sends appropriate headers so the user is prompted by the browser to download the file. For example, exporting to an Excel spreadsheet, it sends:
My problem is, I don't know how to get the browser to interpret those headers coming from an XMLHTTP object.
For example, I send the table's innerHTML in a POST request to a server-side script (via an XMLHTTP object):
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
xmlhttp.open("POST", "process.cgi", true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { // do what we need to do } } xmlhttp.send('exportdata='+escape(dataTable.innerHTML));
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
Content-Type: application/vnd.ms-excel Content-Disposition: attachment; filename="1165420852.xls"
![]() |
Similar Threads
- Warning: session_start(): Cannot send session cache limiter - headers already sent (PHP)
- Open In New Window Php (PHP)
- File Attachment Small Problem (PHP)
- Mailform error (PHP)
- Challenging Problem in PASSing Data to Server, Plz Help (ASP)
- Parse Email Headers (PHP)
- Parse XML from ASP!!! (ASP)
- Sending audio data over HTTP problem (Java)
- Fake Microsoft Windows Security Warning (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
Views: 4015 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxexample ajaxjspservlets api blackjack browser bug calendar captchaformproblem checkbox child class close cookies createrange() cursor dependent disablefirebug dom dropdown editor element embed engine events explorer ext file firehose flash form forms game gears google gxt hiddenvalue highlightedword html ie7 ie8 iframe image() images internet java javascript javascripthelp2020 jquery jsf jsfile jump libcurl margin math matrixcaptcha media mp3 mysql object onerror onmouseoutdivproblem onreadystatechange parent passing paypal pdf php player post progressbar rated regex runtime scroll search security session shopping size software solutions sql star stars stretch synchronous text textarea tweet unicode web webkit webservice window windowsxp wysiwyg xspf \n





