Added some sanitation and consistency for bad function call in AJAX