Javascript examples for jQuery Method and Property:ajaxSend
The ajaxSend() method sets a function to run when an AJAX requests is about to be sent.
Parameter | Description |
---|---|
function(event,xhr,options) | Required. |
Additional parameters:
The following code shows how to change the content of a <div> element when an AJAX requests is about to be sent:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(document).ajaxSend(function(e, xhr, opt){ $("div").append("<p>Requesting " + opt.url + "</p>"); });/*from www. j a va2 s. c o m*/ $("button").click(function(){ $("div").load("demo_ajax_load.asp"); }); }); </script> </head> <body> <div><h2>Let AJAX change this text</h2></div> <button>Change Content</button> </body> </html>