Note that there are some explanatory texts on larger screens.

plurals
  1. POInterrupting an looping function
    primarykey
    data
    text
    <p>I trigger the following function when a tooltip is clicked. It is an ajax poll.</p> <p>There can be many tooltips on the page, and more than one can need access to the data retrieved from the server.</p> <p>What I want to achieve is to have this poll running as one instance - so if the user clicks a different tooltip the polling stops, rather than being duplicated.</p> <p>Would be grateful if you could help.</p> <p>Thanks</p> <pre><code>function doConversationsAjaxLongPoll(tablename){ clientSubmit = new Object; // HERE WE'RE GOING TO GET A LIST OF THE ROWIDS THAT WE NEED TO POLL FOR, MAKE AN OBJECT OUT OF THEM. DO THIS BY LOOKING AT WHICH //TOOLIPS HAVE CLASS OPEN var tooltips = []; $('.tooltipOpen').each(function(index){ tooltips.push($(this).data('idrow')) }) console.log("tooltips length: " + tooltips.length) if(tooltips.length==0){ // console.log("tooltip length is 0 so we're returning false") return false } clientSubmit.OpenConversations = tooltips clientSubmit.tablename = tablename clientSubmit.CurrentData = $('body').data('conversations') console.log(clientSubmit) $.ajax({ type: 'POST', url: '/conversations.php?loadNew=1', data: clientSubmit, timeout: 25000, success: function(data){ console.log('success') data=JSON.parse(data) console.log(data) $('body').data('conversations', data) }, complete: function(status, jqXHR){ if(tooltips.length==0){ // console.log("tooltip length is 0 so we're returning false") return false } else { doConversationsAjaxLongPoll(tablename); } } }); updateConversations() } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload