The only thing that differs in the AJAX request sent with jQuery compared to the regular request (regardless of the regular request) is the X-Requested-With: XMLHttpRequest HTTP header, which is added. This header can be deleted as follows:
$.ajax({ url: '/foo', type: 'POST', data: { bar: 'baz' }, beforeSend: function(xhr) { xhr.setRequestHeader( 'X-Requested-With', { toString: function() { return ''; } } ); }, success: function(result) { alert(result); } });
or globally, for all AJAX requests on your site:
$.ajaxSetup({ beforeSend: function(xhr) { xhr.setRequestHeader( 'X-Requested-With', { toString: function() { return ''; } } ); } });
source share