Fix undefined index error in ajax_add_term function