Ho trovato e adattato il seguente codice php alle mie esigenze, se lo lancio tramite il tag HREF il download parte, ma se lo faccio passare attraverso una chiamata AJAX, non accade nulla...

Codice PHP:
    function filterData(&$str){        $str preg_replace("/\t/""\\t"$str);
        
$str preg_replace("/\r?\n/""\\n"$str);
        if(
strstr($str'"')) $str '"' str_replace('"''""'$str) . '"';
    }

    
$fileName "lista.xls";
    
$fields = array('PERIFERICA''MARCA''MODELLO''S/N GESTORE''LOCATION');
    
$excelData implode("\t"array_values($fields)) . "\n";

    
$crews = new crews();
    
$query $crews->esegui_query("SELECT * FROM t_periferiche ORDER BY periferica ASC;");
    foreach(
$query as $record)
    {
        
$lineData = array($record['periferica'], $record['marca'], $record['modello'], $record['sn_gestore'], $record['posizione']);
        
array_walk($lineData'filterData');
        
$excelData .= implode("\t"array_values($lineData)) . "\n";
    }

    
header("Content-Type: application/vnd.ms-excel");
    
header("Content-Disposition: attachment; filename=\"$fileName\"");
    echo 
$excelData;
    exit; 

codice:
varxmlhttp;

functionesporta()
{
xmlhttp = GetXmlHttpObject();

if (xmlhttp==null)
    {
alert ("Il Browser non supporta HTTP Request");
return;
    }

varf = document.forms["esportazione"];
varsection = f.elements["section"].value;
varordina = f.elements["ordina"].value;
varurl = "section="+section+"&ordina="+ordina;

xmlhttp.open("POST","php/cute/esportaLista.php",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", url.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange = stateChanged;
xmlhttp.send(url);
}

functionstateChanged()
{
if (xmlhttp.readyState == 4)
    {
xmlhttp.responseText;
    } else {
document.getElementById("txtHint").innerHTML = '<span class="red">Esportazione in corso...</span>';
    }
}

functionGetXmlHttpObject()
{
if (window.XMLHttpRequest)
    {
returnnewXMLHttpRequest();
    }
if (window.ActiveXObject)
    {
returnnewActiveXObject("Microsoft.XMLHTTP");
    }
returnnull;
}

Il codice mi restituisce la risposta "Esportazione in corso..." e lì rimane fermo, il download non parte, dove sbaglio e come posso risolvere?

Grazie