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

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看