Friday 29 November 2013

Reload the Page via AJAX using Jquery

/** Reload the Page via AJAX using Jquery. */
(function () {
 $('#dvLoading').fadeOut(10); // To Switch Off the loader..

 location.reload();
 
} ()); 

Wednesday 27 November 2013

To serialise the Input Form field by ID using Jquery

/** To serialise the Input Form field by ID using Jquery. */
var formData = new FormData(document.getElementById("fieldId"));
alert(formData);

Wednesday 20 November 2013

Jquery function to auto scroll to the page to any position in Javascript

Please find the below function to make auto scroll of the page based on the parameter provided.

/** Auto Scroll to Top. */
var autoScrollToTop = function (value) { 
 
 //var scrollTopVal = 90; 
 if (typeof value == 'undefined') { 
  var scrollTopVal = 90;
 }
 else if ((value != "") && isNaN(value)) {
  scrollTopVal = $(value).offset().top;
 }
 else if (value > 0 ) {
  scrollTopVal = value;
 }
 //alert(scrollTopVal);
 $('html, body').animate({ scrollTop: scrollTopVal }, 500); // 500 (mili second) or 'slow'
};

// The function can be called as below;
autoScrollToTop() // Type: Blank, (Default:90)-> Scroll to 90px from top.
autoScrollToTop(0) // Type: Zero -> Top scroll to very top
autoScrollToTop(150) // Type: Numeric -> Scroll to Provided Numeric value(150px) from top.
autoScrollToTop('.className'); // Type: 'className' -> Auto calculate the distance from top to that className component
autoScrollToTop('#elementID'); // Type: 'elementID' -> Auto calculate the distance from top to that elementIDcomponent