Hello. There is a hardware failure with the laptop not the AC charger. AC chargers have some range of protections of their own. If the power requirements of the laptop are bigger then what the charger can handle, the charger will turn off. Also other parameters can bring the charger offline. In your case, you have a problem with a small chip, the battery charge controller unit, witch regulates the amount of current required to propperly charge the battery. When this thing fails, the charging requirements for the battery are reported rong and the AC charger is forced to give more power then necesary. This results in disconnection of the AC charger ( an internal fail safe of the
AC charger) and the laptop to swich back to battery power. When the laptop is turned off, it can charge the battery because the power requirements are low, having all processor, main board, hard disk etc turned off. Therefore the AC charger can handle the load. However you will need to have it checked by a service center as it is a hardware fault. Both AC charger and laptop needs that check.
The charge controll circuit needs to be replaced probably. It will be a somewhat expensive repair. Don't buy any other battery untill you have the laptop checked.Acer Aspire 7520