javascript - Retrieving data from sqlite3 via ajax from php to js -


in js want read data sqlite3 dbase. here ajax code:

function getheatercfg(rdate){         var data  =  {                 isdaterequested : 1,                 reqdate : rdate         };          var jdata = json.stringify(data);         alert(jdata);         $.ajax({                 url: 'getlatestcfgheater.php',                 type: 'post',                 datatype: 'json',                 data: {'querysettings': jdata},                 success: function(data) {                         console.log("success");                         //parse data                 }         }); } 

and here php code:

<?php      function var_error_log( $object=null ){                 ob_start();                    // start buffer capture                 var_dump( $object );           // dump values                 $contents = ob_get_contents(); // put buffer variable                 ob_end_clean();                // end capture                 error_log( $contents );        // log contents of result of                    var_dump( $object )     }               $db = new sqlite3('./../../yyyy/config.db');             $jsondata = json_decode($_post['querysettings']);              var_error_log(json_decode($jsondata));             $isdaterequested = $jsondata->isdaterequested;             if ($isdaterequested == true) {                     $date = $jsondata->reqdate;                     $stmt = $db->prepare('select * cfgs date \'(?)%\'');                     $stmt->bindvalue(1, $date);             }             else {                     $stmt = $db->prepare('select * cfgs');             }              $ressql = $stmt->execute();             var_error_log($ressql);             echo json_encode($ressql);     ?> 

and here php error.log:

[thu jan 07 14:37:37 2016] [error] [client xxxx] php warning:  json_decode() expects parameter 1 string, object given in /var/www/fullcalendar-1.5.3/demos/getlatestcfgheater.php on line 15, referer: http://xxxx/fullcalendar-1.5.3/demos/sel3.html [thu jan 07 14:37:37 2016] [error] [client xxxx] null\n, referer: http://xxxx/fullcalendar-1.5.3/demos/sel3.html [thu jan 07 14:37:37 2016] [error] [client xxxx] object(sqlite3result)#4 (0) {\n}\n, referer: http://xxxx/fullcalendar-1.5.3/demos/sel3.html [thu jan 07 14:37:37 2016] [error] [client xxxx] php notice:  undefined index: querysettings in /var/www/fullcalendar-1.5.3/demos/getlatestcfgheater.php on line 13, referer: http://xxxx/fullcalendar-1.5.3/demos/sel3.html [thu jan 07 14:37:37 2016] [error] [client xxxx] null\n, referer: http://xxxx/fullcalendar-1.5.3/demos/sel3.html [thu jan 07 14:37:37 2016] [error] [client xxxx] php notice:  trying property of non-object in /var/www/fullcalendar-1.5.3/demos/getlatestcfgheater.php on line 16, referer: http://xxxx/fullcalendar-1.5.3/demos/sel3.html [thu jan 07 14:37:37 2016] [error] [client xxxx] object(sqlite3result)#3 (0) {\n}\n, referer: http://xxxx/fullcalendar-1.5.3/demos/sel3.html 

shall use method instead post? why json_decode on php side complaining?

chorme says that

 jdata = "{"isdaterequested":1,"reqdate":"7-1-2016"}" 

so think valid json format...

can please point me how can data? reagrds j.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -