update ajax code to return on fail