Liam
Liam

Reputation: 9855

AJAX return data fadeIn()

I use AJAX to insert data into my table, once this is done however I want my new value to fade in, inplace of the existing .html data.

I have the following only it doesnt seem to fade in...

// UPDATE INCOME 
     $("#salary-upd").on("submit", function(event) {
          event.preventDefault();
          var elem = $(this);
          $.post("update_salary.php", $(this).serialize(), function(data) {
                $(".spends").fadeIn().html(data);
     });

Upvotes: 1

Views: 185

Answers (3)

Selvakumar Arumugam
Selvakumar Arumugam

Reputation: 79830

Try,

   $(".spends").fadeOut('slow', function() { 
      $(this).html(data).fadeIn('slow'); 
   });

Upvotes: 1

Ram
Ram

Reputation: 144699

you can do it this way:

  $(".spends").append(data).fadeIn();

Upvotes: 1

McGarnagle
McGarnagle

Reputation: 102783

Try this one. Set the initial value to start, then do the animation explicitly:

$(".spends").css('opacity', 0).animate( { opacity: 1 }, 'slow');

Upvotes: 0

Related Questions