0

I am doing project with jquery mobile framework using zend framework.I have the page to download report in csv format. I can downloaded it from desktop version. But the same page in mobile version runs in ajax due to jquery mobile result undefined with blank page.

for example, i call this http://www.test.com/report/downloadtransaction when i click download button. This calls downloadtransactionAction in reportcontroller ,then finally gives csv file. Call is happening in mobile version but not able to see download file window.

Below is the code

 public function downloadtransactionAction(){
                    $preview_result = getmySessionData('preview_result')->preview_key;
                    //print_obj($preview_result);        
                    $myFile = "TRANSACTION_" . time() . ".csv";
                    header("Content-Disposition: attachment; filename=\"$myFile\"");
                    header("Content-Type: application/vnd.ms-excel; charset=UTF-16LE");
                    $out = fopen("php://output", 'w');
                    //$csvData = array('Warehouse Id', 'Name','Item No','Minimun Stock','Current Stock');
                    $csvData = array('No','DATE','USER', 'TRADE TYPE','AMOUNT');
                    $o = fputcsv($out, $csvData, ',', '"');
                    $count = 1;;
                    foreach($preview_result as $key => $value)
                    {

                        $csvData = array();
                        $csvData = array($count,date('Y/m/d',strtotime($value['date'])),$value['current_admin_name'],($value['trade_type'])?'WithDraw' : 'Deposit',$value['amount']);
                        $o = fputcsv($out, $csvData, ',', '"');
                        $count++;
                    }
                    fclose($fh);
                    // DOWNLOAD CSV
                    echo $out;
                    die;
    }

I need to download csv in mobile version as like in desktop version What i done wrong on this ?

4

1 回答 1

0

我使用下面的代码来禁用 jquery 移动框架中的 ajax,

        <script type="text/javascript">
            // do not handle links via ajax by default
            $(document).bind("mobileinit", function () { $.mobile.ajaxEnabled = false; });
        </script>

这将禁用页面中的 ajax 并重定向到单击的页面。

于 2012-06-26T12:17:12.620 回答