I am trying to get value from Jquery Ajax, but it is not getting.
The problem is in the below code:
<?php
header('Content-Type: application/json');
if(isset($_GET['od'])){
$deotd = $_GET['od'];
}
date_default_timezone_set('Asia/Calcutta');
$cdate = date('Y-m-d H:i:s ', time());
$scdate = strtotime($cdate);
$e = $scdate - $deotd;
$f = "2700" - $e;
// You would calculate a real value here
echo json_encode([
'tleft' => $f
]),
json_encode([
'diffex' => $e
]);
?>
In deep the problem is with:
echo json_encode([
'tleft' => $f
]),
json_encode([
'diffex' => $e
]);
But what is the problem, I am unable to solve it.
echo json_encode(['tleft' => $f]), json_encode([ 'diffex' => $e]);You're callingjson_encodetwice, and the second time as a second argument of the first. You should combine them into one array and calljson_encodeonly onceecho json_encode([ 'tleft' => $f, 'diffex' => $e ]);