In trains they may have a reservoir, or the urine and feces may simply fall on the tracks, hence the notice which appears in many train toilets: "Please do not flush while the train is standing at a station".
In the year 2500 BCE, the people of Harappa in India had water borne toilets in each house that were linked with drains covered with burnt clay bricks.
The invention of the flush toilet is credited to Sir John Harington in 1596, though it took improvements in the Victorian era (likely spearheaded by Alexander Cummings rather than Thomas Crapper as is commonly stated) for flushing toilets to become widely used.