checking id's before making ajax call