This issue can be caused by to distinct reasons:
Heating issues - some laptops have built-in heat sensors that will stop charging if the battery, or the laptop itself gets hot. This can be remedied by turning off the laptop for a while to allow it to cool down. It may be worth cleaning the cooling ducts and CPU/GPU heatsinks with compressed air/vacuum.
Battery Driver issues - the default Windows battery device drivers may be corrupt, or incompatible with your particular brand of laptop. If the issue is persistent, it may be worth downloading newer drivers directly from your manufacturer. Below is a solution for resetting the Windows 7 default ACPI battery drivers.
Follow the steps below to fix battery charging driver issues:
1. Disconnect AC power
2. Shut down laptop
3. Remove battery
4. Connect AC power
5. Start laptop
6. Open "Device Manager" (right-click on "Computer" -> Properties -> click "Device Manager" in left pane)
7. Under "Batteries", right-click and uninstall "Microsoft ACPI Compliant Control Method Battery" (all occurances)
9. Disconnect AC power, insert battery
10. Connect AC power, start laptop
Note: If following the above steps does not fix your issue, it may be worth using a voltmeter to verify the voltage coming out of the power supply at the point where it plugs into your laptop. Some power supply cables are prone to failure after repeat bending, and adapters can fail as well. Most common laptop PSUs should output about 19 volts, and there is a label on them that lists the input and output voltages.