Prussia was not defeated by Denmark in the First Schleswig War, but was forced to withdraw by the Great Powers (principally Russia and Austria) who threatened war if they did not do so. This marked a temporary end to Prussian expansionism, until the end of the Austro-Russian alliance (brought about by the foolish Austrian decision to join the anti-Russian side of the Crimean War) left Prussia's enemies at odds with one another.
Source: Iron Kingdom by Christopher Clarke.