spinner – Should a dialogue close before a mutating change is accepted?

I have a simple setup dialog

Some settings: [     ]

[Update] [Cancel]

When the user clicks "Update", the application sends a request to the server to update the user settings.

Should the dialogue close before or after this request? I can think of three different behaviors here, and I'm not sure what's best:

  1. The dialog box remains open until the server responds successfully (in which case the dialog closes) or when it fails (in which case the error is reported). Meanwhile, maybe the "Update" button turns into a spinner or some other indication that something is going on.

  2. The dialog box closes immediately and the settings displayed in the main page of the application are immediately updated on the client side. When the server returns, if it fails, a notification (pop-up message? Under the? Settings) tells the user that it has failed.

  3. The dialog box closes immediately, but the settings on the application's main page change to a spinner, which resolves to the server's return.