I need:
1) Get data from server by button click. (can ajax)
2) Execute some js depending on the received data.
3) Show standard "File save as" dialog.
It must work in IE7/IE8/FF.
Thanks! And sorry for my crooked english =)
You can call a PHP file using ajax, which looks like this:
header("Content-Type: application/octet-stream");
header("Content-Length: " . filesize($fileContent));
header("Content-Disposition: attachment; filename=\"".$fileName."\"");
echo $fileContent;
This will display the "save as" dialog box in all browsers.
filename= is not a valid header. You probably mean Content-Disposition: attachment; filename="...". The Content-Transfer-Encoding is also superfluous, and none of the headers should contain a trailing ;.