refactored json ajax with popup