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 response.result is set to true or false, it will be considered as if an ajax call was already made and the response object will directly be passed onto lwaAjax().

You can also add the response.skip property set to true and further action by calling lwaAjax() will be skipped too.

statusElement The status element as a jQuery object, used to display an error or confirmation message, by default is:
<span class="lwa-status" role="alert"></span>

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!';
				});