Ainsworth, who signed for the Dons for £2million from Port Vale in 1998, agreed terms with the Welsh side over the weekend and signed a contract after passing a medical on Monday.
He has registered in time to make his Cardiff debut in their second division clash with Blackpool at Ninian Park on Tuesday night.