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

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条)

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)