If you get this error please go to Settings > Themes and change themes to a different theme.
Then go to Settings > Advanced and change the 'upgrade_via_ajax' value from 1 to 0 and Save.
Then go back and do an Upgrade as normal.
After the Upgrade is completed, go back to Settings > Advanced and change upgrade_via_ajax from 0 to 1
Then go to Settings > Themes and return to your previous theme selection.