$.getjson () Visit time.php page, time.php page return data

Source: Internet
Author: User
Index.htm page:

function UpdateTime () {
$.getjson ("time.php",
function (data) {
alert (data);
now = Data.time;
}
);

}

time.php page:
{"Time": 1454237138}//Returns a time, 1454237138 indicates the number of seconds

Now my question is: {"Time": 1454237138} needs to return the current time instead of returning a fixed time.


Reply to discussion (solution)

time.php page
echo json_encode (Array (' time ' = Time ()));

time.php page:

echo json_encode (Array (' time ' = Time ()));
?>
Moderator, is that so? But there is no result, is not the return JSON format is not correct, please advise

time.php page
echo json_encode (Array (' time ' = Time ()));

Still no results, my time.php page:
echo json_encode (Array (' time ' = Time ()));
?>


time.php page
echo json_encode (Array (' time ' = Time ()));

Still no results, my time.php page:
echo json_encode (Array (' time ' = Time ()));
?>


You try alert (data.time) and see what happens?



time.php page
echo json_encode (Array (' time ' = Time ()));

Still no results, my time.php page:
echo json_encode (Array (' time ' = Time ()));
?>


You try alert (data.time) and see what happens?

No reaction.

You can open the browser debugging function to see if the sent request has been successfully

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.