We demonstrate a novel method that integrates quantum state preparation of polar molecular ions and the detection of spatially resolved fluorescence in specific regions to study the high-precision spectroscopy of ${\mathrm{HD}}^{+}$ molecular ions in traps. The detection technique not only enables real-time signal measurement but also suppresses common-mode noise arising from fluorescence fluctuations and reduces the state redistribution induced by blackbody radiation. Thus, this method overcomes the key limitations encountered during quantum state preparation of polar molecules through resonance-enhanced threshold photoionization. By utilizing this approach, we measured the ($v, N$): $(0,\phantom{\rule{0.16em}{0ex}}0)\ensuremath{\rightarrow}(6,\phantom{\rule{0.16em}{0ex}}1)$ rovibrational transition of ${\mathrm{HD}}^{+}$ ions, with an unperturbed frequency of 303.396 506 7(20) THz. This value is in excellent agreement with the predictions of quantum electrodynamics (QED). Looking forward, our method could be extended to detect hot-band transitions of $\mathrm{H}{\mathrm{D}}^{+}$ excited from highly excited rovibrational states. This provides high-precision tools for determining fundamental constants such as the proton-to-electron mass ratio and for exploring the unknown contributions of QED.