English 中文(简体)
jquery php 长期投票申请
原标题:jquery php long polling request issue

I m 进行长途投票(例如this)和PHP和jQuery。 在浏览器上下载整页后,一项功能向投票人提出长期要求,并有一定的排位限制,如果数据来自背后,再次提出长期污染要求,如果出现任何错误,它将再次提出新的长期污染要求。

问题:通过火力分析痕量,我注意到,长期投票请求有3或4次,但不应。 仅应有一页长的污染要求。

然而,该法典完美运作,但长期提出的重复要求是问题。

function listen_for_message(){ 
// this functions is makes the long-polling request
$.ajax({
  url: "listen.php",
  timeout:5000,
  success: function(data) {
            $( #display ).html(data);
            listen_for_message();
             }
  error: function() {
            setTimeOut("listen_for_message()",2000); // if error then call the function after 2 sec
  }
    });
    return;
}
最佳回答

Try to terminate request Manualy:

var connection;
function longpoll() {
   if(connection != undefined) {
      connection.abort();
   }

   connection = $.ajax({ 
       ...
       complete: function() {
          longpool();
       }
   });
}

也可以是Perth/firebug问题(将bor断的连接进行操作),在 Chrome进行测试。

最新资料:

"In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period." http://api.jquery.com/jQuery.ajax/

问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签