Improved error handling with jQuery and moved js to bottom of template