fixed ajax call in loop