By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

new window with php header via ajax, is it possible?

P: 130
hello all

i am trying to create an excel report file to download
i have saw few examples in this site and work with them,

this is whats going on:

main.php have a form that the user choose date to extract his report,
then with ajax i return the table affter being generated from mysql.

the code that i echo to the ajax request is a <table> tag.

the problem is that affter i echo the table i also want to echo the excel,

Expand|Select|Wrap|Line Numbers
  1. if($xls_file=="1"){//if the user want excel file aswell 
  2.     $xlsxls = header("Content-type: application/msexcel");
  3.     $xlsxls .= header("Content-Disposition: attachment; filename=xldoc.xls");
  4.     $xlsxls .= $final;//thats the <table> that ajax echo
  5.     echo $xlsxls;
  6. }
this just produce the same table twice, is there a way to tell ajax to open it in a new window i belive that will solve it.

is there other solution?
Apr 22 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 16,027
Try using an iframe to force the download.
Apr 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.