First, try charging it while the laptop is turned off rather than on and see if that works. If it does charge when turned off, but not when turned on, then you probably need to replace the charger.
When they aren't working correctly, it is very common for them to not put out enough power to both run the laptop and charge the battery. Hence working when turned off. Eventually it won't work then either.