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 6936415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:13:51+00:00 2026-05-27T12:13:51+00:00

my jquery isn’t auto refreshing, with the following code, is there any issue with

  • 0

my jquery isn’t auto refreshing, with the following code, is there any issue with it(seeBelow). I basically want it to check if any new bids have been placed and then update the html 🙂

EDIT:

function checkBids(){
    var id = $('div.auction').attr('id') 
    $.ajax({
        url: 'http://localhost/tinybid/index.php/auction/auctiondata',
        dataType: 'json',
        success: function(json){
                if (json['i'] = 'product'+id) {
                    $('li.user').html(json['u']);
                    $('li.curPrice').html(json['p']);
                }
            }
    }); 
}

$(document).ready(function() {
    setInterval(checkBids, 1000);
});

Here is the auctiondata –

function auctiondata(){
        $this->load->model('Auction_model', 'Auction');
        $this->load->model('Bid_model', 'Bid');
        $this->load->model('Customer_model', 'Customer');

        $auctions = $this->Auction->getAllAuctions();

        foreach ($auctions as $auction){
            $lastBid = $this->Bid->getLastBid($auction['auction_id']);
            $user = $this->Customer->getUserById($lastBid['user_id']);
            $bid = strtotime($lastBid['end_time']);

            $json[] = array(
                'i' => $auction['auction_id'],
                't' => $bid,
                'p' => '£ '.$auction['current_price'],
                'u' => $user['username']
            );  
        }

        echo json_encode($json);
    }

EDIT 15:13 15/12/2011:
here is the json output from the data :
[{“i”:”1″,”t”:1323961871,”p”:”£ 0.23″,”u”:”joe2011uk”},{“i”:”2″,”t”:1323957557,”p”:”£ 0.03″,”u”:”joe2011uk”}]

the page is displaying the previous bid for i:1,

still not updating

Can anyone help, thanks for your time

Kerry 🙂

  • 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-05-27T12:13:52+00:00Added an answer on May 27, 2026 at 12:13 pm

    You need to remove the () from the way you pass checkBids to setInterval.

    By suffixing the function name with (), you are calling checkBids, and passing the return value to setInterval – which in your case in null (because you don’t call return at any point). This will result in checkBids being called once, and only once.

    A function is like any other “value” (object) in Javascript – you pass it around just as you would a string or a number.

    You can do what @Shvelo suggested and use the syntax you used, but wrap it in quotes to turn it into a string. However, you should not do this – this effectively means that setInterval calls eval() on the string you passed, which is inefficient and prone to errors. JSLint will not like you for doing it either.

    Change

    setInterval(checkBids(), 1000);
    

    to

    setInterval(checkBids, 1000);
    

    Also, swap your two code segments around – you should define your function before you try and use it anywhere.

    EDIT

    After the long discussion below, I think you want to do this in you success function.

    If you give your individual auction <div>s IDs of auction<id>, where <id> is the numeric ID returned in json['i'], then do this:

     // ...
     success: function(json) {
       for (var i = 0; i < json.length; i++) {
         $('#auction'+json[i]['i']+' li.user').html(json[i]['u']);
         $('#auction'+json[i]['i']+' li.curPrice').html(json[i]['p']);
       }
     }
     // ...
    

    I think it should do what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some code that's basically identical to the jQuery UI Sortable example here:
Why isn't jQuery intergrated into browsers, so there would be no need to have
I have a piece of jquery code that isn't firing correctly in IE (8
I'm using the following code to create a Dialog box using JQUERY/UI: var $dialog2
I want to trigger jQuery from a GMap info window. I have these code
I am trying to use the following jQuery code to add a div with
the jQuery tablesorter plugin isn't working too well for one specific case. Basically, I
I have a django project, but for some reason basic jquery isn't working. <html>
using jquery ui 1.8 trying autocomplete Everything works apart from that the ui-menu isn't
jQuery and JavaScript in general are new ground for me. What are some good

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.