The golden rule is to attend to the spill or stain as quickly as possible to minimise the risk of permanent damage. For larger soiled areas please refer to a specialist carpet cleaner.
Place a colourfast cloth or paper towel over the spill and apply reasonable pressure to draw up as much liquid as possible. If the stain is still apparent, you will need to repeat the process and if necessary moisten with water or a solution of mild detergent (ideally material appropriate detergent, i.e. wool detergent for a woolen rug). Ensure you remove all traces of the detergent by diluting the stained area with minimal water and then draw as much of the liquid up as possible again. You can cover it with a colourfast cloth and weigh down the area for a few hours. Never saturate or vigorously rub the stain.
First remove the solids with a spoon, knife or brush taking care not to brush too harshly. Moisten the affected area with a diluted material appropriate cleaning product or mild detergent and soak up this liquid with a colourfast cloth as outlined above.
Never mix different cleaning solutions. Cleaning chemicals can react unpredictably with each other, and it is best to consult a professional when you are unsure of the outcome.