Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery and PhP: Adding Animations
    primarykey
    data
    text
    <p>I am creating a a random number generator that has a big blue button, that you click. As soon as you click it, I use jquery and ajax to submit the form without refreshing the page. I get a random number between 0 and 100. What I do is that I replace the value of the button with the number that was generated. Here is the code that I have...</p> <pre><code>$('form.roll').on('submit', function() { var that = $(this), url = that.attr('action'), type = that.attr('method'), data = {}; that.find('[name]').each(function (index, value) { var that = $(this), name = that.attr('name'), value = that.va(); data[name] = value; }); $.ajax ({ url: url, type: type, data: data, success: function(response) { $(function() { $("#roll").val(response); }); } }); console.log(data); return false; }); </code></pre> <p>and here is the button</p> <pre><code>&lt;input type="submit" class="btn btn-primary btn-lg btn-block" id="roll" value="Roll Dice"&gt; </code></pre> <p>Now this seems to work, but it does not look good. I would like to animate it. What I want to do is that is kind of flashes in, stays for a few seconds, and then slowly fades away back to "roll dice", like the animation here: (just click on superuser and change it, you will see the animation. <a href="http://vitalets.github.io/x-editable/demo.html" rel="nofollow">http://vitalets.github.io/x-editable/demo.html</a></p> <p>What i want is that if it is less that 50, the flash is green, and when it rolls more that 50 its red. The number that is displayed is something like "29.67". Two digit number, with two decimals.</p> <p>I would also like to add loading gif while the php function is being processed.</p> <p>I hope this makes sense, and that you can help me out. Thanks a lot for your time!</p>
    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.
    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