jquery polling with smart poll plugin

一个人想着一个人 提交于 2019-12-03 21:55:13

That is probably a bad example. The callback passed to $.get will only be fired if the request succeeded. Try this:

$.poll(10000, function(retry){
  $.ajax({
      url:'willfail',
      success: function(){
          // Do something
          alert("YES");
      },
      error: function() {
          alert("NO");
          retry();
      }
  });
});

For more information, have a look at $.ajax.

You can also use Smartupdater - jQuery plugin

http://www.eslinstructor.net/smartupdater/

which let you:

  • Stop/Restart polling
  • Change polling timeout dynamically
  • Switch polling URL dynamically
  • Switch callback function dynamically
  • Remotely set polling timeout
  • Remotely select callback function
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!