Ranga14

Gotpix.com JQuery/AJAX Commenting

Aug 14th, 2013
48
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. $('#PP_Post').on('submit', function(e) {
  3.     var $btn = $(this).find('.Submit');
  4.  
  5.     $btn.attr('disabled', true);
  6.     $btn.val('Posting...');
  7.  
  8.     e.preventDefault();
  9.  
  10.     $.ajax({
  11.             type: 'POST',
  12.             data: $('#PP_Post').serialize(),
  13.             url: $(this).attr('action'),
  14.             success: function(msg) {
  15.                 var targetOffset = $('#Profile_Posts').offset().top;
  16.  
  17.                 // Insert post
  18.                 $(msg).insertBefore('#Profile_Posts .most_recent');
  19.  
  20.                 // Scroll to top of posts
  21.                 $("body, html").animate({scrollTop: targetOffset}, 600);
  22.  
  23.                 // Re-enable submit button
  24.                 $btn.removeAttr('disabled');
  25.  
  26.                 // Update button text
  27.                 $btn.val('POST');
  28.  
  29.                 // Clear old post message
  30.                 $('#PP_Post .descriptionField').val('');
  31.             }
  32.     });
  33. });
  34. </script>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×