Example URL https://smarttips.in?newsletter=1 <script> var queryString = (function(url) { if (url == “”) return {}; var smart = {}; for (var i = 0; i < url.length; ++i) { var pS=url[i].split(‘=’, 2); if (pS.length == 1) smart[pS[0]] = “”; else smart[pS[0]] = decodeURIComponent(pS[1].replace(/+/g, “””)); } return pS; })(window.location.search.substr(1).split(‘&’)); $(document).ready(function(){ if(queryString[“newsletter”]==1) { alert(‘Got it!!!’) } }); </script>
Category: jQuery
avoid select2 search box
Comaparatively select2 is faster than select box.Select2 is an alternative of select box with search option. We can avoid this select2 search box by adding the following script: jQuery(“#dd-from,#mm-from,#yy-from,#dd-to,#mm-to,#yy-to,#time-from,#time-to”). select2({ minimumResultsForSearch : -1 });
jQuery get($.get) or post( $.post) error catching
In jQuery generally using two methods for data posting. There is a chance of happening errors, for tracking get or post error use a jQuery fail() method. If error occurred will return to jQuery fail() method. $.post(“url”,function(userdata){ alert(userdata) ); }).fail(function(){ // error code here alert(‘page not found’) });
How To Install Node.js Framework with Express and socket.io modules
1. Get a repository or package of node.js using following command sudo apt-get install nodejs 2. After that we need a NodeJS package manager (npm) sudo apt-get install npm Run the node.js using the command node node.js node.js supports different modules Examples : socket.io ,express,http..etc var socket = require( ‘socket.io’ ); var express = require( ‘express’ ); var…
copy to clipboard using jQuery
<a href=”javascript:void(0);” id=”userlinkId” style=”display: inline;”>http://localhost/profile/sijo</a> <script type=”text/javascript”> jQuery(document).ready(function(){ jQuery(“a#userlinkId”).zclip({ path:’js/ZeroClipboard.swf’, copy:jQuery(‘#userlinkId’).text(), beforeCopy:function(){ jQuery(‘#userlinkId’).hide(); jQuery(‘#copymessage’).css(‘color’,’red’); jQuery(‘#copymessage’).html(‘Copied to clipboard’); jQuery(‘#copymessage’).delay(2000).fadeOut(400); }, …