Improved error JS error handling for ajax requests, added spinner