It depends on the kind of jam, but it's a mixture of approaches.
Learning familiarity with chordshapes so that one can recognise what others are playing is a great help, as cornfedgroove said. That's especially true of guitar chords. Everyone and his dog plays guitar, so you can be sure that there will usually be guitarists at most jams (informal or organised).
Most jamming is based on standard structures rather than TOTALLY improvised from scratch. Either a song will be the starting point, or just a chord progression. It's helpful to be familiar with the most common progressions as these will occur most often.
Examples are:
I, IV, V - used in 12 bar blues (usually with dominant 7 versions thrown in to taste).
I, vi, IV, V - used in many rock and roll and doo-wop songs.
I, V, vi, IV - used in many pop, rock and reggae songs.
It's good to learn the progressions by their numbers (I, IV, V or 1, 4, 5) because then you can figure out the progression in any key by simply counting the intervals off on your fingers.
If you just learn it as a list of chords in a key, for example G, C , D, then you can find yourself stuck if someone calls out for a 12 bar in A or in E. If you know it more generically as a I, IV, V progression you can just start with the A or E (or any tonic note) and count up 4 and 5 steps to find the other chords in the tune.