lwa_pre_ajax
JS Hook
Fired after a login, registration or password recovery form is submitted but before any AJAX call is made, allowing circumventing an AJAX call entirely by modifying the response
object. No spinners are added at this point.
Parameters
response
|
The response object returned by AJAX call. If the
You can also add the |
statusElement
|
The status element as a jQuery object, used to display an error or confirmation message, by default is:
|
Examples
The following example will prevent the AJAX call from firing and immediately return an error message by manualy modifying the statusElement
element.
jQuery(document).on('lwa_pre_ajax', function( event, response, form, statusElement ){
response.result = false;
response.skip = true;
statusElement.removeClass('lwa-status-confirm')
.addClass('lwa-status-invalid')
.html('Will not proceed!');
});
A further example acheives the same thing, but instead lets LWA handle the response
which we add the response.error
message to and do not set the response.skip
property.
jQuery(document).on('lwa_pre_ajax', function( event, response, form, statusElement ){
response.result = false;
response.error = 'Will not proceed either!';
});