We use neutron scattering to study the effect of electron doping on the structural or magnetic order in BaFe2As2. In the undoped state, BaFe2As2 exhibits simultaneous structural and magnetic phase transitions below 143 K. Upon electron doping to form BaFe1.96Ni0.04As2, the system first displays the lattice distortion near approximately 97 K, and then orders antiferromagnetically at 91 K before developing weak superconductivity below approximately 15 K. The effect of electron doping is to reduce the c-axis exchange coupling in BaFe2As2 and induce quasi-two-dimensional (2D) spin excitations. These results suggest that the transition from 3D spin waves to quasi-2D spin excitations by electron doping is important for the separated structural and magnetic phase transitions in iron arsenides.