A search for absorption of MG and CA compounds in molecular clouds towards Galactic continuum sources