Fixed loading issue with jquery dom loading function