Jquery Ajax with BlockUI Plugin

    I love making Ajax calls and if a user is interacting with a page and doesn't need to refresh or be redirected to another page than an Ajax call is the best thing to use in my opinion. With my best efforts I try to give my users an experience where every action has a result. This means everything even if the reaction is simple or does nothing more than alert the user. I like to let the user know that all is fine and meant to be the way it is. If an error happens they should be alerted as well. Which I should also try to prevent and recover from, but what about with an ajax call that takes a while to process? Well I have been using a really cool process with my code where I can display to my users that the process is going through. With "Please wait..." message users can see it is order is being processed and controls will returned to them when it has completed.
    You can see an example here and to go a step further then this I thought this would be a cool place to implement Gamification, by providing a small and simple game in place of the "Please Wait...". It wouldn't be meaningful for those short to medium time periods but more for those really long processing times. You could be argued that the time to developer this game could better be spent researching on how to shorten those long processes but why not do both if you can make work fun! I leave it to the users on how to spend their time. 

Problems I faced...
I had issues where I was making an ajax call but the Block was not appearing, so what I can did is use the beforeSend() and error() settings like so...
beforeSend : function() {
               $.blockUI({ message: 'OK' });
            }, 
success : function(){
               $.unblockUI();
            },
error : function() { //Close regardless
             $.unblockUI();   
             alert("ERROR!");
        }
Resources
jQuery.ajax() | jQuery API Documentation
Jquery plugin blockUI not working with ajax - Stack Overflow
jQuery BlockUI Plugin


Popular posts from this blog

Aspetcore: NLog with Postgresql

Mongodb Cheatsheet

Installing Windows on Acer chromebook 15 cb3-532