HI
I am getting this error: Uncaught SyntaxError: Unexpected token function in line setInterval(function(){ (line 5)
Someone can tell me what i wrong done ?

    $.ajax({ 
        type:"POST", 
        url:'getmessage.php', 
        data:{user_id:id},
        setInterval(function(){
            success: function(data){ 
            $('.umsg'+id).append(data);
            },
        }, 2000),
    });

Recommended Answers

$(document).ready(function(){
        var ajaxcall = function(){
          $.ajax({
            method:'post',
            url:'getmessage.php',
            data:{user_id:id},
            success:function(data){
              //do somthing
            }
          });
        }
        setInterval(ajaxcall,1000);
      });


  i think ur syntax is wrong..
Jump to Post

All 3 Replies

??? i dont understand

please tell me why it is givving me this error

$(document).ready(function(){
        var ajaxcall = function(){
          $.ajax({
            method:'post',
            url:'getmessage.php',
            data:{user_id:id},
            success:function(data){
              //do somthing
            }
          });
        }
        setInterval(ajaxcall,1000);
      });


  i think ur syntax is wrong..
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.