嗨,我是 javascript 新手,我编写了一个 javascript 代码供用户下载两个 .csv 文件 1)下载等待时间报告和 2)下载原始等待时间报告 下面是 javascript 代码:
$(document).ready(function () {
<?php $array =
getCompiledRawDataForAverageWaitTimeStatisticOfMerchant($startDate, $endDate,
$merchantID, $paxStart, $paxEnd);
array_unshift($array,array("transactionID"=>"transactionID","merchantID"=>"merchantID","mobileNum"=>"mobileNum","capacity"=>"capacity","remarks"=>"remarks","queueStartTime"=>"queueStartTime","status"=>"status","statusTime"=>"statusTime","numPings"=>"numPings","minTime"=>"minTime","time before ping"=>"time before ping","day"=>"day"));?>
var items = <?php
echo json_encode($array);?>;
console.log(items);
var jsonObject = JSON.stringify(items);
var csv = ConvertToCSV(jsonObject);
a=document.createElement('a');
a.textContent='Download Waiting Time Report';
a.download="waitTime.csv";
a.href='data:text/csv;charset=utf-8,'+escape(csv);
document.body.appendChild(a);
///Second thing to code:
//document.write("\n");
<?php $array2 =
getAllRawDataForAverageWaitTimeStatisticOfMerchant($startDate, $endDate, $merchantID,
$paxStart, $paxEnd);
array_unshift($array2,array("transactionID"=>"transactionID","merchantID"=>"merchantID","mobileNum"=>"mobileNum","capacity"=>"capacity","remarks"=>"remarks","queueStartTime"=>"queueStartTime","final status"=>"final status","final statusTime"=>"final statusTime","status"=>"status","minTime"=>"minTime","numPings"=>"numPings","time before status change"=>"time before status change","day"=>"day"));?>
var items2 = <?php
echo json_encode($array2);?>;
console.log(items2);
var jsonObject2 = JSON.stringify(items2);
var csv2 = ConvertToCSV(jsonObject2);
a=document.createElement('a');
a.textContent='Download Raw Waiting Time Report';
a.download="RawWaitTime.csv";
a.href='data:text/csv;charset=utf-8,'+escape(csv2);
document.body.appendChild(a);
});
请帮助每次我尝试插入断行语句时,控制台都会读取错误