diff --git a/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee b/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee index 624352f49c..645144022c 100644 --- a/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee +++ b/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee @@ -52,9 +52,10 @@ createXHR = (options, done) -> # Sending FormData will automatically set Content-Type to multipart/form-data if typeof options.data is 'string' xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8') - xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest') unless options.crossDomain - # Add X-CSRF-Token - CSRFProtection(xhr) + unless options.crossDomain + xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest') + # Add X-CSRF-Token + CSRFProtection(xhr) xhr.withCredentials = !!options.withCredentials xhr.onreadystatechange = -> done(xhr) if xhr.readyState is XMLHttpRequest.DONE