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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Amzul
    New Member
    • Oct 2007
    • 130

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

    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,

    [CODE=php]if($xls_file==" 1"){//if the user want excel file aswell
    $xlsxls = header("Content-type: application/msexcel");
    $xlsxls .= header("Content-Disposition: attachment; filename=xldoc. xls");
    $xlsxls .= $final;//thats the <table> that ajax echo
    echo $xlsxls;
    }[/CODE]
    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?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Try using an iframe to force the download.

    Comment

    Working...