Tag: jQuery

Add Request Header to jQuery Ajax Requests

Sometimes it is necessary to determine if a request was performed by a jQuery Ajax call or a normal request. Using ajaxSetup it is possible to add custom headers to all Ajax requests executed by jQuery.

   'beforeSend': function(xhr) {           
      xhr.setRequestHeader("AJAX", "true");

Server-side you can then check the request header to identify the type of request and output the appropriate response.

Posted in Programming | Tagged | Leave a comment