To get the most from your food, aim to eat 2 to 3 hours before working out. This meal should contain carbohydrates, proteins, and fats. If you have to eat closer than this, remember that the foods you choose should be faster digesting.
Because fats are slow to digest, if it's less than 1 hour before training then just stick to faster digesting carbohydrates and faster digesting proteins. The fastest digesting proteins you can eat are Whey Proteins. The fastest digesting carbohydrates are Pure Dextrose and Pure Maltodextrin – but I wouldn't recommend these carbs for everyone. If your goal is weight loss focussed, then if you have to eat close to training, sticking to a protein shake is usually best.