search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

0 answers
Q&A jQuery - Call ajax every 10 seconds
jQuery - Call ajax every 10 seconds
P粉521013123 2026-01-04 16:22:16 Views 68
PHP

0

I have a mysql feedback database constructed like this:

name | location | feedback

Ryan | England | great support

Obviously there's more entries than that. I am trying to build a feedback div, where it displays a new feedback item every 10 seconds via ajax.

So I have constructed this:

$(document).ready(function(){
   new get_fb(); 
 });

function get_fb(){
var feedback = $.ajax({//Ajax
                        type: "POST",
                        url: "feedback.php",
                        async: false
                        }).responseText;//end of ajax

$('div.feedback-box').html(feedback).delay(10000).queue(function() {
    new get_fb(); 
    });
}

And here's my PHP file:

$result = mysql_query("SELECT * FROM feedback ORDER BY RAND() LIMIT 0,1");
while($row = mysql_fetch_array($result))
{
    $name = $row['name'];
    $location = $row['location'];
    $feedback = $row['feedback'];

    echo "
    

Name: $name, Location: $location, Feedback: $feedback.

"; }

However, this only shows two. It doesn't keep showing new ones, it purely shows the first then the second and stops.

What am I doing wrong? Thanks :)

Your Answer
submit

0 answers

Popular tool

vc9-vc14 (32+64 bit) runtime library collection (link below)

vc9-vc14 (32+64 bit) runtime library collection (link below)

Download the collection of runtime libraries required for phpStudy installation

VC9 32-bit

VC9 32-bit

VC9 32-bit phpstudy integrated installation environment runtime library

PHP programmer toolbox full version

PHP programmer toolbox full version

Programmer Toolbox v1.0 PHP Integrated Environment

VC11 32-bit

VC11 32-bit

VC11 32-bit phpstudy integrated installation environment runtime library

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use