The invention relates to a preparation method of an HfxTa1-xC alloy precursor and an HfxTa1-xC alloy obtained through the method. The method comprises the steps that 1, hafnium tetrachloride is dispersed in a solvent, monobasic alcohol is dripped into the solvent, triethylamine is dripped into the solvent, after monobasic alcohol and triethylamine are completely dripped, reflux is conducted, filtration is conducted, and a hafnium alkoxide solution is obtained; 2, a chelating agent is dropwise added into the hafnium alkoxide solution, after the chelating agent is completely dripped, reflux is conducted, water and monobasic alcohol are added, after the water and monobasic alcohol are completed dripped, reflux is conducted, and polyhafnoxane is obtained through vacuum distillation; 3, tantalum pentachloride is dispersed in the solvent, monobasic alcohol is dripped into the solvent, triethylamine is dripped into the solvent subsequently, after monobasic alcohol and triethylamine are completely dripped, reflux is conducted, filtration is conducted, and a tantalum alkoxide solution is obtained; 4, a chelating agent is dropwise added into the hafnium alkoxide solution, after the chelating agent is completely dripped, reflux is conducted, water and monobasic alcohol are added, after the water and monobasic alcohol are completed dripped, reflux is conducted, and poly tantalum oxane is obtained through vacuum distillation; 5, polyhafnoxane, poly tantalum oxane and allyl phenol are mixed, and a hafnium tantalum alloy precursor is obtained. The prepared alloy precursor is good in solubility and stable storage life and can serve as a fiber reinforced ceramic-based composite material matrix for use.