Since you mentioned in your update that it works when you navigate to the endpoint via the address bar, why not have the button act as a link that navigates there? Instead of trying to force whatever you are doing with ajax.
You can set the link target to "_blank" so that the opened link does not interrupt the current page.