* [ jQuery ](https://jquery.com/ "jQuery")
  * [ jQuery UI ](https://jqueryui.com/ "jQuery UI")
  * [ jQuery Mobile ](https://jquerymobile.com/ "jQuery Mobile")
  * [ Sizzle ](https://sizzlejs.com/ "Sizzle")
  * [ QUnit ](https://qunitjs.com/ "QUnit")

  * [ Plugins ](https://plugins.jquery.com/)
  * [ Contribute ](https://contribute.jquery.org/)
    * [ CLA ](https://cla.openjsf.org/)
    * [ Style Guides ](https://contribute.jquery.org/style-guide/)
    * [ Bug Triage ](https://contribute.jquery.org/triage/)
    * [ Code ](https://contribute.jquery.org/code/)
    * [ Documentation ](https://contribute.jquery.org/documentation/)
    * [ Web Sites ](https://contribute.jquery.org/web-sites/)
  * [ Events ](https://events.jquery.org/)
  * [ Support ](https://jquery.com/support/)
    * [ Learning Center ](https://learn.jquery.com/)
    * [ Chat ](https://jquery.com/support/)
    * [ Stack Overflow ](https://stackoverflow.com/tags/jquery/info)
    * [ Report a bug ](https://contribute.jquery.org/bug-reports/)
  * [ OpenJS Foundation ](https://openjsf.org/)
    * [ Join ](https://openjsf.org/about/join/)
    * [ Members ](https://openjsf.org/about/members/)
    * [ jQuery Team ](https://jquery.com/team)
    * [ Governance ](https://openjsf.org/about/governance/)
    * [ Conduct ](https://code-of-conduct.openjsf.org/)
    * [ Donate ](https://openjsf.org/about/project-funding-opportunities/)

##  [ jQuery API Documentation ](https://jquery.com/ "jQuery API
Documentation")

Navigation

  * [ Download ](https://jquery.com/download/)
  * [ API Documentation ](https://api.jquery.com/)
  * [ Blog ](https://blog.jquery.com/)
  * [ Plugins ](https://plugins.jquery.com/)
  * [ Browser Support ](https://jquery.com/browser-support/)

#  ajaxSend event

* * *

Categories:  [ Ajax ](https://api.jquery.com/category/ajax/) > [ Global Ajax
Event Handlers ](https://api.jquery.com/category/ajax/global-ajax-event-
handlers/)

##  .on( "ajaxSend", handler )  Returns: [ jQuery
](http://api.jquery.com/Types/#jQuery)

**Description:** Attach a function to be executed before an Ajax request is
sent. This is an [ Ajax Event ](/Ajax_Events/) .

  * ####  version added: [ 1.7 ](/category/version/1.7/) .on( "ajaxSend", handler ) 

    * **"ajaxSend"**

Type: [ string ](http://api.jquery.com/Types/#string)

The string ` "ajaxSend" ` .

    * **handler**

Type: [ Function ](http://api.jquery.com/Types/#Function) ( [ Event
](http://api.jquery.com/Types/#Event) event, [ jqXHR
](http://api.jquery.com/Types/#jqXHR) jqXHR, [ PlainObject
](http://api.jquery.com/Types/#PlainObject) ajaxOptions )

The function to be invoked.

This page describes the ` ajaxSend ` event. For the deprecated ` .ajaxSend() `
method, see [ ` .ajaxSend() ` ](/ajaxSend-shorthand/) .

Whenever an Ajax request is about to be sent, jQuery triggers the ` ajaxSend `
event. Any and all registerd ` ajaxSend ` handlers are executed at this time.

To observe this method in action, set up a basic Ajax load request:

1  2  3  | 
    
    
    <div class="trigger">Trigger</div><div class="result"></div><div class="log"></div>  
  
---|---  
  
Attach the event handler to the document:

1  2  3  | 
    
    
    $( document ).on( "ajaxSend", function() {  $( ".log" ).text( "Triggered ajaxSend handler." );} );  
  
---|---  
  
Now, make an Ajax request using any jQuery method:

1  2  3  | 
    
    
    $( ".trigger" ).on( "click", function() {  $( ".result" ).load( "ajax/test.html" );} );  
  
---|---  
  
When the user clicks the element with class ` trigger ` and the Ajax request
is about to begin, the log message is displayed.

All ` ajaxSend ` handlers are invoked, regardless of what Ajax request is to
be sent. If you must differentiate between the requests, use the parameters
passed to the handler. Each time an ` ajaxSend ` handler is executed, it is
passed the event object, the ` jqXHR ` object (in version 1.4, `
XMLHttpRequest ` object), and the [ settings object ](/jQuery.ajax/) that was
used in