Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7780873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:02:45+00:00 2026-06-01T19:02:45+00:00

New with jQuery. Here’s what I have so far – basically, I want jQuery+ajax

  • 0

New with jQuery. Here’s what I have so far – basically, I want jQuery+ajax to get the most current date for a certain item. The script refreshes every 1 second.

This is the script:

<script>
var auto_refresh = setInterval(
function()
{
$.ajax({
    type: "POST",
    url: "gettime.php",
    data: ({i : <?=$itemid;?>}),
    function(data){
        var s = data;
    }
});
var t = s.split(/[- :]/); //split time from mysql
var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
$('#defaultCountdown').countdown({until: d,compact: true, 
description: ''});
}, 1000);
</script>

And here’s gettime.php

<?php 
include("inc/dblink.inc");
$itemid = intval($_POST['i']);
$row = mysql_fetch_array(mysql_query("SELECT * FROM test WHERE itemid='$itemid' ORDER BY bidid DESC LIMIT 0,1"));
$date = $row['date'];
echo $date; //sample date is 2012-04-13 10:03:37
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:02:46+00:00Added an answer on June 1, 2026 at 7:02 pm

    You have to do everything inside the ajax callback, because data and s are only available there (and when it runs):

    var auto_refresh = setInterval(function(){
        $.ajax({
            type: "POST",
            url: "gettime.php",
            data: ({i : <?=$itemid;?>}),
            complete: function(data){
                var s = data;
                var t = s.split(/[- :]/); //split time from mysql
                var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
                $('#defaultCountdown').countdown({until: d,compact: true, description: ''});
            }
        }); 
    }, 1000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have application that brings response via Ajax and creates 5-20 new jQuery click
I'm new to JQuery and so far I'm using prototype. But now I want
I'm new to jQuery and have been following the tutorial here for a Panel
I'm new to jquery deferreds. Here I have a simple example . Can anybody
I have a bit of an issue here. As Im new to jQuery this
I'm new to jQuery and ajax, and so am trying to get this simple
i am very new at jquery and code, here i am trying to get
Hallo, i am new to jquery, AJAX requests. Here is my html code in
new to jquery here and I've come up with an Ajax box to appear
new to jquery here, right now I have a working hide/show function when one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.