Improved AJAX request and fixed POST passing

added frontend feedback for AJAX request
formatted PHP script in sections