javascript - Links within refreshing div not working -


i'm following example below continuously refresh div mysql table.

http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery

i'm using complete , timeout parameter of ajax refresh div instead of using setinterval , settimeout.

the problem i'm having returning data can include links , these not working when clicked. believe problem div refreshing , click ignored. how allow links within refreshing div? works setinveral , settimeout want use long polling allow real time updates.

here code.

// page url variables function geturlvars() {     var vars = {};     var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {         vars[key] = value;     });     return vars; }  // set var parent id scroll var tid = geturlvars()["tid"];   var pid = geturlvars()["pid"];  (function poll(){      // latest page     $.ajax({           url: "ajax.tickets_details.php?tid=" + tid,         type: 'get',           cache: false,           success: function(html) {              // print results in div             $("#ticket_updates").html( html );          },          complete: poll,         timeout: 30000      });  })(); 

thanks!

i've read tutorial , it's based on false information.

this tutorial says:

this means our poll function won't called again until both ajax call complete , (at-least) thirty (30) seconds have passed.

this isn't true. if request returns in < 30s it fire again immediately, causing problem. actual definition of timeout is:

set timeout (in milliseconds) request. override global timeout set $.ajaxsetup(). timeout period starts @ point $.ajax call made; if several other requests in progress , browser has no connections available, possible request time out before can sent. in jquery 1.4.x , below, xmlhttprequest object in invalid state if request times out; accessing object members may throw exception. in firefox 3.0+ only, script , jsonp requests cannot cancelled timeout; script run if arrives after timeout period.

so means if request takes more 30s cancel waiting handler only (not call itself, continue javascript handler go out of scope).

there comment highlighting flaw: enter image description here

i'd find new tutorial 1 appears talking nonesense. technique not doing "server push" @ all. web sockets can push server. http 1.1 not support server push methods @ all.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -