. Ajaxsuccess (Handler (event, XMLHttpRequest, Ajaxoptions))
Returns
jquery Description:
Ajaxsuccess (Handler (event, XMLHttpRequest, Ajaxoptions))
Handler (event, XMLHttpRequest, ajaxoptions) The function to be invoked.
Whenever an AJAX request completes successfully, triggers the ajaxsuccess jquery event. Any and all have been used. The Ajaxsuccess () method registers a handler that is executed at this time.
To comply with this approach, we can build a basic AJAX load requirement:
<div class= "Trigger" >trigger</div>
<div class= "Result" ></div>
<div class= "Log" ></div>
We can put any element in our event handler:
$ ('. log '). Ajaxsuccess (function () {
$ (this). Text (' triggered ajaxsuccess handler. ');
});
Now, we can use any one of the Ajax requests for jquery
$ ('. Trigger '). Click (function () {
$ ('. Result '). Load (' ajax/test.html ');
});
The user clicks the button and the AJAX request completes successfully, the log displays the message.
Note:. Since Ajaxsuccess () is implemented as an instance method of a jquery object, we can use the This keyword, because what we're doing here refers to the element that is selected in the callback function.
When all ajaxsuccess handlers are invoked, no matter what AJAX requests are completed. If you must distinguish between the requirements, we can use the parameters passed to the handler. Every time a ajaxsuccess handler executes, it is through the event object, the XMLHttpRequest object, and the set object are the requirements used in the creation. For example, we can limit the processing-specific URLs that handle only our callback events:
$ ('. log '). Ajaxsuccess (function (E, XHR, settings) {
if (Settings.url = = ' ajax/test.html ') {
$ (this). Text (' triggered ajaxsuccess handler. ');
}
});
For example:
Displays a message when an AJAX request completes successfully.
$ ("#msg"). Ajaxsuccess (function (evt, request, settings) {
$ (this). Append ("<li>successful request!</li>");
});