I'm making an AJAX call to a site which generates a query and then saves it to a .txt file.
This file should be downloaded after the AJAX was done and close that download window.
Howether IE closes it automatically and then tries to close the mainwindow, which shouldn't be closed.
Meanwhile Chrome only closes the download window which is what IE should do aswell..
Is there a workaround for this?
function start(){
$.ajax({
url: ('query.php'),
type: 'POST',
async:false,
data: {
id: id,
intnr: intnr
},
dataType: "html"
})
.done (function(response) { window.open('download.php'); window.close('download.php'); })
.fail (function(xhr, textStatus, errorThrown) { alert(xhr.responseText); })
;
}
download.php is just :
<?php
header ( 'Content-Type: text/html');
header ( "Content-Disposition: 'attachment'; filename='File.txt'");
include ('/xx/xx/query.txt');
?>
EDIT : Workaround but it is working now..
shortened function to
.done (function(response) { var download_window = window.open('download.php'); })
added into download.php
<script>
var s = navigator.userAgent;
if(s.indexOf("Chrome") > -1 == true)
{
window.open('', '_self', '');
window.close();
}
</script>