Categories
jQuery

Load JSON encoded data using jQuery.getJSON()

Using jQuery.getJSON method you can get or load JSON encoded data by an AJAX HTTP GET request. The method returns XMLHttpRequest object. JSON stands for JavaScript Object Notation. So, this is a way of formatting the data to look at loading JSON data using an HTTP GET request (you can also use POST method). Syntax: […]

Categories
jQuery

Download a HTML content as pdf using javascript – jsPDF

Using jsPDF library, you can download the div containing graphs, tables, contents as a PDF. This is a HTML5 client-side solution for generating PDFs. Simply include library in your <head>, generate your PDF using the many built-in functions, then create a button to trigger the download. <script type=”text/javascript” src=”http://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js”></script> Create a object: var doc = […]

Categories
jQuery

Difference between $.each(selector) and $(selector).each()

In jQuery, there is an object iterator utility called $.each() as well as a jQuery collection iterator: .each() to run for each matched element. We can return false to stop the loop early. Syntax: $(selector).each(function(index,element)) Basically, $.each() is essentially a drop-in replacement of a traditional for or for-in loop. So, .each is an iterator which […]

Categories
jQuery

Abort Ajax requests using jQuery

Using jQuery abort() you can cancel a running AJAX request forcefully before it ends as this hits several times within a short time period. This is usually in cases where the user might perform an action, based on AJAX request several times within a short time period. For example, There is a auto-complete functionality for […]

Categories
Javascript jQuery

Difference between window.location.href and location.reload

window location href and location reload() both redirects a page to a new page but there are some difference to follow. Here is the difference between window.location.href and location.reload: window.location.href is not a method. It is a property which will tell you the current URL location of the browser. Changing the value of the property […]

Categories
jQuery

Select an element with multiple classes in jQuery

The basic concept of jQuery is to select one or more elements using element ID, Class, Attribute, Compound CSS Selector and do something with them. Let’s see how to select an element with multiple classes. For simple selection you can use following code as below. Selecting Elements by ID: $( “#Id” ); Selecting Elements by […]

Categories
jQuery

jQuery get() Method

jQuery get() method sends an HTTP GET request to a page load data from the server back. If any request with jQuery.get() method returns an error code then it will fail without notification unless the script has also called the global .ajaxError() method. In other side, as of jQuery 1.5, the .error() method of the […]

Categories
jQuery

How to disable jQuery animations

The jQuery.fx.off method is used to globally enable or disable jQuery animations whose default value is false which allows animations to run normally. Syntax: jQuery.fx.off = true|false; $.fx.off = true|false; The true value specifies that the animations should be disabled and the false value is default value which specifies that the animations should be enabled. […]

Categories
jQuery

Difference between prop and attr in jQuery

The prop and attr both method sets or returns properties/attributes and values of the selected elements. Let’s see the difference between Attr and Prop in jQuery. prop() grabs the specified DOM property whereas attr() grabs the specified HTML attribute. To know more about jQuery prop(), click here. To know more about jQuery attr(), click here. […]

Categories
WordPress

Turn off Canonical URLs – WordPress SEO by Yoast

Yoast SEO works in a way to choose a focus keyword for your articles, and then makes sure that you use that focus keyword everywhere. But Yoast SEO turns the canonical URLs ON always. It has different types of features: – Page Analysis – Search Engine Optimization – XML Sitemaps – Meta & Link Elements […]