fix jquery ajax and q deferred to handle error