Working on Custom extension development, sometimes you need to integrate third party APIs for easy access of tools by requesting and response from server. Recently, we came across requirement of returning JSON data from controller while calling ajax in Magento 2.
Attachment 13526
for more: How to Return JSON Data from Controller While calling AJAX in Magento 2