Refactors widget ajax controller