dpwdsmbvm496180204 2013-03-01 18:52
浏览 44
已采纳

Javascript函数如何?

I'm using WebIM for chat support on a website. I would like to be able to setup a timer for when a client initiates a chat session, if an operator/tech does not respond within 'x' seconds I would like the page to redirect to another page where the client can leave a message.

Sortof a 'please hold while we try to connect you' thing. That way if all the techs are too busy or helping other clients the client waiting can simply try back later or leave a message (as such when chat is offline).

I looked extensively over mibew.org the creators of the chat script, there is nothing regarding this feature, also it looks as though their website has just about been abandoned.

I have come up with an idea of using Javascript setTimeout function to run some php after 'x' amount of time. The php will basically query the DB to see if a tech has entered the session in question and if not then redirect the client to another page explaining that no one is available at the moment, but they can leave a message, etc.

Problem is, I don't have much of any experience with JS.

Is this a possibility? Is there another more effective/efficient was to accomplish this?

  • 写回答

4条回答 默认 最新

  • drebew5059 2013-03-01 18:56
    关注

    Yes, you can do that.

    You can use the timeout function to perform a javascript function every x seconds.

    var time = 200;
    setTimeout(function()
    { 
        func(); 
    }, time);
    

    Then make the function perform an ajax call, asking for some result from the database, and do something depending on the results.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?