State machine ajax