Small error in the json file which made it incorrect. Also added JSON header in the ajax.php file.