diff --git a/lib/IHP/static/helpers.js b/lib/IHP/static/helpers.js index 039cea78a..633d181a5 100644 --- a/lib/IHP/static/helpers.js +++ b/lib/IHP/static/helpers.js @@ -296,7 +296,15 @@ window.submitForm = function (form, possibleClickedButton) { 'Content-Type', 'application/x-www-form-urlencoded' ); - request.send(parameters.join('&')); + + try { + request.send(parameters.join('&')); + } catch (e) { + // If the send method throws an exception, redirect to the form action URL. + // This can happen for example if redirecting to an external site, which doesn't have CORS enabled, + // so we can't use Ajax. + window.location.href = url; + } } var buttons = form.getElementsByTagName('button');