I have AJAX calls as FX function:
$. Ajax ({url: 'link', type: 'post', datatype: 'jason', data: {'txtFromOrderDate': '2014-08-01', 'txtToOrderDate': '2014-08-05'}, success : Function () {Window.location = 'link';}});
As a php function:
public function createZipAction ($ txtFromOrderDate, $ txtToOrderDate) {date_default_timezone_set ('Australia / Melbourne'); $ Date = date ('m: d: y h: i: s', time ()); $ ExportBatch = $ date; $ Order = $ this- & gt; GetTableGateway ('command'); Select $ = New Select (); $ 'Select- & gt; From ('Order') - & gt; Join ('user', 'order.user_id = user.id', array ('email')) - & gt; Where ("order.created." $ .txtFromOrderDate. "And" 2014-08-03 "); // -> Where (between 'order.created' '$ TxtFromOrderDate.' And '. $ TxtToOrderDate); $ Data = $ order- & gt; Select (select $) - & gt; ToArray (); $ Batchdir = __DIR__ '/../../../../data/export/batch/' $ ExportBatch; If (is_dir ($ batchDir) == incorrect) mkdir ($ batchDir); $ CsvFile = fopen ($ batchdir. '/order.csv', 'w'); $ I = 0; Foreign currency (dollar data $ record) {if ($ i == 0) fputcsv ($ csvFile, $ this-> getCsvHeader ($ record)); Fputcsv ($ csvFile, $ this-> updatesCSYWillline ($ records)); $ PngTmpFile = $ this- & gt; Savedementimage image ($ record ['plate_id']); $ This- & gt; SavePlayPdf ($ pngTmpFile, $ exportBatch, $ record ['id']); Unlink to ($ pngTmpFile); $ I ++; } Fclose ($ csvFile); $ Filter = new \ zend \ filter \ compress (array ('adapter' = & gt; 'zip', 'option' => array ('collection' = & gt; $ batch .Dir '.zip') )); $ Filters & gt; Filter ($ batchDir); $ FileToDownload = $ batchDir '.zip'; $ This- & gt; DownloadOrderCSVAction ($ fileToDownload); The echo "has been exported: $ i record."; Die (); }
The dates of this time are being supplied, its dates are not available.
But when I write a hard code in the PHP function:
$ txtFromOrderDate = '2014-08-01' $ txtToOrderDate = '2014-08-05'
then works as expected forward.
What could be the issue ???
Please help me.
When you post to PHP (through AJAX in your case), those data variables Are not set in the global form. They are set in the $ _ POST
array.
You can use them directly or set them in your global variable (just make sure they check that they exist before).
if (isset ($ _ POST ['you go')) {$ yourVariable = $ _POST ['your variable']; }
Comments
Post a Comment