0

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.

9
  • 1
    Where's your ajax? Commented Nov 10, 2017 at 16:55
  • echo json_encode(['tleft' => $f]), json_encode([ 'diffex' => $e]); You're calling json_encode twice, and the second time as a second argument of the first. You should combine them into one array and call json_encode only once Commented Nov 10, 2017 at 16:56
  • try to echo only one json you can have both keys and values in there Commented Nov 10, 2017 at 16:56
  • @johnSmith How? Commented Nov 10, 2017 at 16:57
  • 1
    @MKJ echo json_encode([ 'tleft' => $f, 'diffex' => $e ]); Commented Nov 10, 2017 at 17:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.