I think the change to .post here causes the error handling to stop working, as JQuery instead is catching the 404 returned from Foreman when no templates are configured.  You probably need to use .ajax and define an error function rather than using .post (you can still set `type: 'post'` with .ajax).