Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery delay won't work
    primarykey
    data
    text
    <p>I'm trying to get a delay in a jQuery sequence but is refuses to work.</p> <pre><code>var old = $('.likes' + id).text(); $('.likes' + id).text("You've already voted").delay(3000).text(old); </code></pre> <p>Now, the old text gets entered right away with out the 'you've already voted' ever being displayed.</p> <p>Any suggestions? </p> <p>EDIT:</p> <p>As requested:</p> <p>HTML:</p> <pre><code>&lt;li&gt; &lt;h2&gt;&lt;a href="?page=dub&amp;id=%%DUB_ID%%"&gt;%%DUB_TITLE%%&lt;/a&gt;&lt;/h2&gt; &lt;div class="dub"&gt; &lt;iframe width="560" height="315" src="http://www.youtube.com/embed/%%YOUTUBE_ID%%?hd=1" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt; &lt;div id="conten_wrapper"&gt; &lt;div id="conten_meta"&gt; &lt;p&gt; Posted by: &lt;a href="?page=profile&amp;id=%%USER_ID%%"&gt;%%USERNAME%%&lt;/a&gt;&lt;br /&gt; Likes: &lt;span class="likes%%DUB_ID%%"&gt;%%LIKES%%&lt;/span&gt;&lt;br /&gt; Date posted: %%DATE%% &lt;/p&gt; &lt;/div&gt; &lt;div id="conten_social"&gt; &lt;a href="javascript:void(0);" onclick="javascript:makeRequest(\'like\', %%DUB_ID%%)" class="likebtn"&gt;Like&lt;/a&gt;&lt;a href="javascript:void(0);" onclick="javascript:makeRequest(\'dislike\', %%DUB_ID%%)" class="likebtn2"&gt;Dislike&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/li&gt; </code></pre> <p>js:</p> <pre><code>function makeRequest(name, id){ $.ajax({ type: "GET", url: "ajax.php", data: "name=" + name + "&amp;id=" + id, success: function(msg){ var obj = jQuery.parseJSON(msg); if(obj.status == "SUCCES"){ $('.likes' + id).html(parseInt($('.likes' + id).html(), 10)+1); }else { var old = $('.likes' + id).text(); $('.likes' + id).text("You've already voted").delay(3000).text(old); } } }); } </code></pre>
    singulars
    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.
 

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