My text book states that intravenous crystalloid infusion is a method of treating anaphylactic shock.
I can't get why, as there is no fluid loss in case of anaphylactic shock, at least that is what I think.
So why giving crystalloid solution?
Your assumption that there is no fluid loss is wrong. In addition to the vasodilation Jan mentioned in his answer, there's significant fluid loss caused by increased permeability of the vasculature. The result is a massive fluid shift from the intravascular to extravascular space. This explains why swelling occurs in mucus membranes: fluid is leaking out of blood vessels into the surrounding tissue.
Anaphylactic shock is caused by vasodilation and vascular leakage resulting from enhanced permeability of the postcapillary venules in the vascular beds of visceral organs, skin, and mucous membranes.
The commonest cardiovascular manifestation is severe hypotension, usually caused by a massive shift of fluid from the intravascular to the extrayascular space. Arrhythmias are not uncommon. Profound losses of intravascular volume can occur quickly as a result of increased vascular permeability.
In anaphylaxic shock, vasodilation can result in severe hypotension. The aim of crystalloid infusion is to help correct hypotension. There are various treatment regimes possible, but most authors suggest (for adults):