A library for unobtrusive ajax using data-ajax*
attributes.
data-ajax
: required Enables unobstrusive ajaxdata-ajax-update
: required Element to update the response withdata-ajax-method
: OverrideGET
fora
,method
forform
. Set ajax method forinput
,select
,button
andtextarea
. Can beGET
,POST
,PUT
,DELETE
data-ajax-url
: Overridehref
fora
,action
forform
. Set ajax URL forinput
,select
,button
andtextarea
data-ajax-loading
: Show an element (e.g., spinner) while performing ajax calldata-ajax-confirm
: Confirm message to show before triggering the ajax. If not confirmed, then ajax action is not performed. Not applicable oninput
,select
andtextarea
data-ajax-mode
: How to replace the element specified indata-ajax-update
. Default is to replace inner html. Other options:BEFORE
,AFTER
,REPLACE-WITH
(Replace inner html including element)
data-ajax-disable
: Disable the element during ajax operationdata-ajax-disable-with
: Disable the element during ajax operation with a message
Events triggered on the element attached with [data-ajax]
:
ajax-before
: Triggered before request is prepared. Can be cancelled by returningfalse
. Event Handler Parameters(event, element, clickedElement)
ajax-before-send
: Triggered before request is sent. Can be cancelled by returningfalse
. Event Handler Parameters(event, element, xhr, settings, clickedElement)
. Can be used to changesettings
andxhr
configajax-send
: Triggered when request is sent. Event Handler Parameters(event, element, xhr, settings, clickedElement)
ajax-success
: Triggered when request is successful. Event Handler Parameters(event, element, xhr, status, data, clickedElement)
ajax-error
: Triggered on request error. Event Handler Parameters(event, element, xhr, status, error, clickedElement)
ajax-complete
: Triggered when request is complete. This event may not trigger as the element may not exists after success response. Event Handler Parameters(event, element, xhr, status, clickedElement)
Event triggered on the element data-ajax-update
:
ajax-before-update
: Triggered before update of the element. Event Handler Parameters(event, element, data)
ajax-updated
: Triggered after successful update of the element. Event Handler Parameters(event, element, data)
- jQuery
- (Optional#) jQuery Validation Unobtrusive with jQuery Validation