javascript - PHP function not getting called through ajax -



javascript - PHP function not getting called through ajax -

i have ajax phone call php function :

$.ajax({ url: 'link', type: 'post', datatype : 'json', data: {'txtfromorderdate' : '2014-08-01','txttoorderdate' : '2014-08-05'}, success: function() { window.location = 'link'; } });

php function as:

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." , '2014-08-03' "); //->where ('order.created between '.$txtfromorderdate.' , '.$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 $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(); }

here when supply dates function, not getting dates.

but when write dates hard-code in php function as:

$txtfromorderdate='2014-08-01' $txttoorderdate='2014-08-05'

then farther function works expected.

what can issue???

please help me.

when post php (via ajax in case), info variables not set globals. set in $_post array.

you can utilize them straight or set them global variables (just ensure check exist before-hand).

if (isset($_post['youvariable')) { $yourvariable = $_post['yourvariable']; }

javascript php jquery ajax

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

java - Parsing XML, skip certain tags -

c# - ASP.NET MVC Sequence contains no matching element -