mumia55
02-18-2009, 02:54 PM
I'm having a curious problem, at least it's curious for me.. that when a start a download on my website, ajax functions stop working, only after the donwload stops, the functions work.
I'm going to show some parts of my code.
downloadfile.php
$fileType = $_GET['tipo'];
$fileSize = $_GET['tamanho'];
$fileContent = $b;
$fileName = $_GET['nome'];
// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache
header("Content-Description: File Transfer");
header("Content-type: $fileType");
header("Content-Length: ".filesize($fileSize));
header("Content-Disposition: attachment; filename=\"".$fileName."\"");
flush();
//for files bigger than 100megabytes
$fp = fopen($fileContent, "r");
while (!feof($fp)){
echo fread($fp, 65536);
flush(); // this is essential for large downloads
}
fclose($fp);
and then my ajax script
response.js
function ajaxAbre(pagina,id){
var xmlHttp;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Seu navegador não suporta AJAX. Atualize-o em www.getfirefox.com");
return false;
}
}
}
xmlHttp.onreadystatechange=function() {
if(xmlHttp.readyState == 1) {
document.getElementById(id).innerHTML = "Carregando...<img src='./images/loading.gif'></img>";
}
if(xmlHttp.readyState == 4) {
document.getElementById(id).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET",pagina,true);
xmlHttp.send(null);
}
ajax code in my website works to change content in certain divs
thanks already! hope someone understand my needs :P
I'm going to show some parts of my code.
downloadfile.php
$fileType = $_GET['tipo'];
$fileSize = $_GET['tamanho'];
$fileContent = $b;
$fileName = $_GET['nome'];
// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache
header("Content-Description: File Transfer");
header("Content-type: $fileType");
header("Content-Length: ".filesize($fileSize));
header("Content-Disposition: attachment; filename=\"".$fileName."\"");
flush();
//for files bigger than 100megabytes
$fp = fopen($fileContent, "r");
while (!feof($fp)){
echo fread($fp, 65536);
flush(); // this is essential for large downloads
}
fclose($fp);
and then my ajax script
response.js
function ajaxAbre(pagina,id){
var xmlHttp;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Seu navegador não suporta AJAX. Atualize-o em www.getfirefox.com");
return false;
}
}
}
xmlHttp.onreadystatechange=function() {
if(xmlHttp.readyState == 1) {
document.getElementById(id).innerHTML = "Carregando...<img src='./images/loading.gif'></img>";
}
if(xmlHttp.readyState == 4) {
document.getElementById(id).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET",pagina,true);
xmlHttp.send(null);
}
ajax code in my website works to change content in certain divs
thanks already! hope someone understand my needs :P