Function existence check on AJAX call