A type of all-optical logical gate based on two kinds of refractive index grating in azo-dye doped polymer film is studied in this paper. Using interference recording method with two 532[Formula: see text]nm laser beams, the transient refractive gratings can be formed in poly(methyl methacrylate) (PMMA) films containing azo-dye Disperse Red 13 (DR13). The characteristics of the transient gratings in films which are recorded by two 532[Formula: see text]nm laser beams with different polarization states are investigated by monitoring the first-order diffraction intensity of the readout He–Ne laser beam (632.8[Formula: see text]nm). It is found that the transient gratings in the polymeric films can be established and decayed in several seconds. Furthermore, we realize XOR and XNOR all-optical logical operation based on the relationship among the polarization states of the recording beams, the reading beam, and the diffraction beam.