mercredi 15 juin 2016

Whats wrong with my ajax/jquery code


I want to change my get data from php page in every 500 miliseconds after pressing button. But I fail. When I remove the condition of click.button it going well. But When I put the condition of click.button its not working. plz help. My Code is below:

    $(document).ready(function(){
    $('#button').click(function(){
        setInterval(function() {
            $.ajax({url: "chat.php", success: function(result){
                $('#get_data').text(result);
            }});
        }, 500);
    });
});

code of chat.php is below

   <?php
echo(rand(10,100));
?>

Aucun commentaire:

Enregistrer un commentaire