Dispersion corrections to electron scattering in 12C and 16O