Issues like this are usually associated with:
- an intermittent connection at the USB connection (check for dirt, foreign materiel, bent pins)
- a bad USB cable (try a different cable)
- a bad USB charger (try a different charger)
- a battery that's gone / going bad (how old is your device and is the battery removable?)
Is the back of the device (i.e., where the battery is) warm (or too warm) to the touch?