Ajax earned a superb 2-1 win over Barcelona to keep alive their hopes of qualifying from Champions League Group H.