0
叫我到PHP函数调用Ajax为:PHP函数没有获得通过Ajax
$.ajax({
url: 'Link',
type: 'POST',
dataType : 'json',
data: {'txtFromOrderDate' : '2014-08-01','txtToOrderDate' : '2014-08-05'},
success: function() {
window.location = 'Link';
}
});
PHP函数为:
public function createZipAction($txtFromOrderDate,$txtToOrderDate)
{
date_default_timezone_set('Australia/Melbourne');
$date = date('m:d:Y H:i:s', time());
$exportBatch = $date;
$order = $this->getTableGateway('order');
$select = new Select();
$select->from('order')
->join('user', 'order.user_id = user.id', array('email'))
->where ("order.created between ".$txtFromOrderDate." and '2014-08-03' ");
//->where ('order.created between '.$txtFromOrderDate.' and '.$txtToOrderDate);
$data = $order->selectWith($select)->toArray();
$batchDir = __DIR__ . '/../../../../../data/export/batch/' . $exportBatch;
if(is_dir($batchDir) == false)
mkdir($batchDir);
$csvFile = fopen($batchDir . '/order.csv', 'w');
$i = 0;
foreach($data as $record) {
if($i==0) fputcsv($csvFile, $this->getCsvHeader($record));
fputcsv($csvFile, $this->updateCsvLine($record));
$pngTmpFile = $this->saveTmpImage($record['plate_id']);
$this->savePlatePdf($pngTmpFile, $exportBatch, $record['id']);
unlink($pngTmpFile);
$i++;
}
fclose($csvFile);
$filter = new \Zend\Filter\Compress(array(
'adapter' => 'Zip',
'options' => array(
'archive' => $batchDir . '.zip'
)
));
$filter->filter($batchDir);
$fileToDownload=$batchDir . '.zip';
$this->downloadOrderCSVAction($fileToDownload);
echo "exported: $i records.";
die();
}
这里的时候,我提供日期此功能,它没有得到日期。
但是,当我在PHP函数写日期硬编码为:按预期工作
$txtFromOrderDate='2014-08-01'
$txtToOrderDate='2014-08-05'
然后进一步的功能。
可能是什么问题???
请帮帮我。
'$ txtFromOrderDate = $ _ POST [ 'txtFromOrderDate'];'等等......当你邮寄到PHP,这些变量没有被设置为全局变量,但$ _POST数组中设置。 – naththedeveloper 2014-10-27 09:28:25
向我们展示您使用POST变量提供方法的代码。此外,查询似乎不安全。有人可以向脚本发送恶意日期(即SQL代码)并执行一些令人讨厌的事情。在使用前你应该清理输入。 – 2014-10-27 09:31:14