我正在我的 PHP 代码中下载一个 CSV 文件,但它没有返回到我的 Ext JS 页面。我的代码如下:
外部 JS 代码
Ext.getCmp('btnExport').on('click', function(button, event)
{
Ext.getCmp("frmReportQuotes").getForm().standardSubmit = true;
Ext.getCmp('frmReportQuotes').getEl().dom.method = 'POST';
Ext.getCmp('frmReportQuotes').getEl().dom.target = '_blank';
Ext.getCmp('frmReportQuotes').getForm().submit({
params: {
output: 'csv'
},
success: function(form, action){
alert('jjkjlkj');
},
failure: function(form, action){
alert('jjkjlkj');
}
});
});
PHP 代码
if (!empty($strOutputType) && $strOutputType == 'csv')
{
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=data.csv");
header("Pragma: no-cache");
header("Expires: 0");
if (!empty($entRequestList))
{
$arrKeys = array();
foreach ($this->view->Data[0] as $key => $value)
$arrKeys[] = $key;
echo '"' . implode('","', $arrKeys) . '"' . "\n";
foreach ($this->view->Data as $entRow)
{
$strCSV = '"' . implode('","', $entRow) . '"';
$strCSV = preg_replace("[\n\r]", " ", $strCSV);
echo $strCSV . "\n";
}
}
die();
}
请帮忙,以便它返回到我的 Ext JS 文件。