Flush output buffers and return JSON to the AJAX caller