28 Jul 2009 1:00 AM #1
How to send HTTP headers to client with ExtJS
Hello, I wish I could do the same as this php code in extjs. The treatment (CSV export) is client side. So, I have sent the data by data url but unfortunalety it does not work on IE8 due to length restriction of the url (FF and chrome it's ok). So I want now to send http headers to send my data. Unless you have another solution ?
switch( $tid )
case "1" : $ctype = "application/pdf"; break;
case "2" : $ctype = "application/xml"; break;
default : return "The file type is corrupt. This is a fairly big problem - please contact us!";
header( "Pragma: public" );
header( "Expires: 0" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Cache-Control: private", false );
header( "Content-Type: $ctype" );
header( "Content-Disposition: attachment; filename=\"" . basename( $fileDir ) . "\";" );
header( "Content-Transfer-Encoding: binary" );
header( "Content-Length: " . filesize( $fileDir ) );
$byteCount = @readfile( "$fileDir" );
28 Jul 2009 1:13 AM #2
28 Jul 2009 1:25 AM #3
But Ajax is for server request ? So I don't want precisely to send something to the server to win time !
28 Jul 2009 2:00 AM #4
i don't know how exactly you send your data, but Ajax extends Connection, which is the basic one. Examine this object and you see how to add headers.
14 Sep 2009 4:57 AM #5
14 Sep 2009 6:07 AM #6
How should that happen? The browser is the client.
14 Sep 2009 6:09 AM #7
14 Sep 2009 6:11 AM #8
14 Sep 2009 6:13 AM #9
Stop and think about it for a sec... There are two computers involved here: the client (that would be, "your PC"), and the server (which runs the web-page you're talking to).
php (or ColdFusion or Ruby or what-have-you) is server-side technology. It's getting your AJAX or HTML requests-for-data and sending back JSON or HTML data to you. This is probably where you need to generate your headers.
ExtJS (and AJAX in general...) is client-side. It's running on your PC.
It is true that both computers are talking to one another using the HTTP protocol. (They may not be exchanging HTML data, but they are using HTTP.) When you send an AJAX request, you therefore can indeed set standard or custom headers, because headers are part of the fundamental definition of what "the HTTP protocol" is. But when you present us with a php example, that tells me that you're interested in the headers that the server is sending to the client ... not the headers that the client (ExtJS) may be sending to the server. All of ExtJS has nothing at all to do with "what the host says."
14 Sep 2009 6:14 AM #10
This is also what I think... But I don't have any absolute certainty, a page on the w3c or whatever that says it is not possible, that's why I am posting this thread...