Create new terminals with POST request to API

This is an alternative to #6846, building on that PR.

In this variant, we create the new window immediately, and then direct it to the newly created terminal when the AJAX response comes back, thereby avoiding the need for synchronous requests to get round popup blockers. This is approach 2 discussed in issue #6849.
Do you want to close the new window on error?