Jquery deferred execution
<p>I'm trying to learn jQuery <code>Deferred</code>s and best way to learn is probably is to try understand them on your own examples. I'm trying to <code>show</code> then <code>fadeout</code> (1000 ms) a message to the user after he clicked button and after ajax succesfully executed. When the user clicks several in  second, message is displayed only once. I would like this scenario:
user clicks 7 times in one second, and that message box shows and fades out seven times in a row. The whole proccess would probably took 7 second.
Few lines of code:</p>

<pre><code>    $("#AddToCart").click(function () {

            var wantedquantity = $("#wantedquantity").val();              
      $.ajax({
                type: "POST",
                url: ROOT + "Cart/AddToCart",
                data: { idd: '@Model.Id', quantity: wantedquantity },
                success: function () {             
                    $("#cartNumber").load(ROOT + 'Cart/_NOfItemsInCart');
                    $("#MessageAddedToCart").css("visibility", "visible").css("display", "block").css("box-shadow", "6px 6px 4px 4px #808080").html("Product added to cart");
                    $("#MessageAddedToCart").fadeOut(1000, function (){
                    });
               }
          });
        });
    });
</code></pre>
