lwa_ajax_complete JS Hook

Triggered after an LWA form is submitted, the AJAX call was made, and any result is processed (success or error). This is trigged after any AJAX attempts are completed, whether success, error or any other status.

Parameters

jqXHR Passed on by the complete function, jQuery jqXHR object, see the jQuery.ajax() settings.complete documenation for more information on this.
textStatus Passed on by the complete function, a string containing the result, such as success or error. See the jQuery.ajax() settings.complete documenation for more information on this.
form The <form> that was submitted as a jQuery object.
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>

Example

The following example will trigger an alert popup if the result of the AJAX attempt was a timeout.


		jQuery(document).on('lwa_ajax_complete', function( event, jqXHR, textStatus, form, statusElement ){
			if( textStatus === 'timeout' ){
				alert('Oops, the website is having some issues... try again shortly!');
			}
		});