Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is one Javascript action executing while the other isn't?
    primarykey
    data
    text
    <p>I have a function that calls jQuery's pulse function. I use it on a small graphic in the client interface that indicates that some data is in the process of being synchronized with the server. While the data is being transferred, the pulse function takes effect, making the graphic look like a flickering light.</p> <p>Alongside that little indicator graphic, is some text. So, when the synchronization is complete, the pulse is stopped, the graphic turns green, and the text says "data synced".</p> <p>All well and good, except that for reasons I don't understand, the function to stop the pulse effect works only about 50% of the time. However, the text that gets changed to say "data synced" works 100% of the time.</p> <p>How is it that I can get to the point in the code where both actions are executed, and yet only one actually happens? It seems to me they should either both work or both fail. (I have tried changing their order, but that does not have any effect on the problem.)</p> <p>Here is the code in question. The first function executes when data begins synchronizing, the other executes when the server sends back a JSON saying "all good: data synchronized".</p> <p>Also note, I'm kind of a noob, so please dumb down answers to my level.</p> <pre><code>function syncDataStart() { $(document.getElementById("indicator")).pulse( { backgroundColor: ["yellow", "orange"] }, 100, 9999, "linear"); document.getElementById("indicator-text").innerHTML = "synchronizing data"; } function syncDataComplete() { document.getElementById("indicator-text").innerHTML = "data synced"; $(document.getElementById("indicator")).stop(); document.getElementById("indicator").style.backgroundColor = "green"; } </code></pre>
    singulars
    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