Friday, February 22, 2019

jquery ajax request with json response

$.ajax({
                        type:'POST',
                        url:'http://mysite.com/url',
                        data:{fieldname: 'fieldvalue'},
                        dataType: "json",
                        success: function(data , status, xhr) {
                              alert('ajax request successful');

                        }, fail:function(data){

                                alert('ajax request failed');
                        }
 });

Friday, February 15, 2019

QR-CODE BARCODE | Scanning field jquery useful script | focus in focus out

  //if scan field exists then focus the field after every second

 if($('.focus-me').length > 0){   

         setInterval(function(){
             $('.focus-me').focus();
         },1000);
       
        //if scan field is not focused then hide "scanner ready" message

         $(".focus-me").focusout(function(){
              $('.focus-in').hide();
              $('.focus-out').fadeIn(500);
         });
       
         //if scan field is focused then hide "scanner not ready" message
         $(".focus-me").focusin(function(){
              $('.focus-out').hide();
              $('.focus-in').fadeIn(500);
         });
       
         //reset the field
         $(document).on('keyup',function(e){
           
                  if (e.key === ' ' || e.key === 'Spacebar') {
                      e.preventDefault();
                      $('.focus-me').val('');
               
                  }
      
         });
       
     }

htaccess Force HTTPS redirect on Subdomain folder and remove www

 Follow is the code

RewriteEngine On
RewriteCond %{SERVER_PORT} 80

#force https
RewriteCond %{REQUEST_URI} subfolder
RewriteRule ^(.*)$ https://www.fdhlpk.com/subfolder/$1 [R,L]

#Remove www from the URL
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]