The visitors were caught cold as Rochdale raced into a 3-0 lead inside the opening 15 minutes.
Their first came when Scott Hogan collected Michael Rose's pass, turned and thumped a vicious drive across Matt Ingram and into the top corner of the net.
The home side soon broke away to score a second, Matt Done racing 60 yards before slipping a pass to Joe Bunney who fired low to Ingram's right.
Rose scored the third, collecting Ian Henderson's corner and curling a 20-yard effort wide of the hapless Ingram.
The visitors pulled one back just before the break through Matt McClure, his stinging low drive beating Josh Lillis in the Rochdale goal.
Jo Kuffour then set up a tense finish when he lifted a shot over Lillis from wide on the left to make it 3-2.
Both sides had chances to score again, Billy Knott firing straight at Lillis and Ingram pulling off fine saves to deny Rose and Done.