lwa_ajax_complete JS Hook

When a LWA form is submitted and an AJAX call was made, after success or error.

Parameters
response The response object returned by AJAX call. You can also add the response.skip property to this object and further action such as adding an error/success message to the top of the form will be skipped. The response parameter will vary according to the action taken, see the PHP hooks lwa_ajax_login, lwa_ajax_remember or lwa_ajax_register for corresponding return values.
jqXHR Passed on by the complete function, jQuery jqXHR object, see the jQuery.ajax() settings.error 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.error documenation for more information on this.
errorThrown When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as Not Found or Internal Server Error. (in HTTP/2 it may instead be an empty string) - as per jQuery.ajax() settings.error documentation.
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 use a generic custom error message when an error occurs by modifying the response object to which we add the response.error message to set the response.skip property to true. We then execute lwaAJAX() ourselves since it will now be skipped by LWA.


		jQuery(document).on('lwa_ajax_error', function( event, response, jqXHR, textStatus, errorThrown, form, statusElement ){
			response.skip = true;
			response.error = "Oops, there was an error...";
			lwaAjax(response, statusElement);
		});