Basic Ajax functionality for the TDI library. Used to bind DOM events to desired HTML elements and send the TDI request when the events fire.
Requires TDI global object.
Namespaces
Methods
-
<static> send(elm, callbacks)
-
Universal method for sending a TDI.Ajax call. It is called internaly for all Ajax enabled elements (like Links, Forms, Selects, Inputs). This method may be used in other scripts as
TDI.Ajax.send( elm );
where theelm
parameter points to the element, which would trigger the Ajax call if it was Ajax enabled.- There are some HTML attributes of the element, which are used to configure the call:
href
The target URL of the Ajax callaction
The same as hrefdata-ajax-url
The target URL of the Ajax call. Used if the Ajax URL should be different than the one defined by href or action attributes, or if the HTML element does not have URL attributes (select, input, ...)method
The HTTP method to be used for the Ajax request. Only for Form elements. Forms with <input type="file"> elements will have forced POST method!data-ajax-method
The HTTP method to be used for the Ajax request. The same as method but applicable for all elements. If used on Form element, it has precedence before method attribute (except Forms with file fields which have always POST method). Defaults to GET.data-related-element
A selector pointing to a related element. This element(s) gets notified when the Ajax call starts/ends.rel
(deprecated; use data-related-element instead) The same as data-related-elementdata-related-ancestor
A selector pointing to a related parent element. This element gets notified when the Ajax call starts/endsdata-confirm
A confirmation message. Use when the user should be able to stop the Ajax calldisabled
The Ajax call does not start if the element has the disabled atribute setclass="disabled"
The Ajax call does not start if the element has a disabled class name
Parameters:
Name Type Description elm
String | jQuery | HTMLElement The element which is used as a trigger for the Ajax call.
callbacks
Object An optional set of callbacks:
beforeStart <Function>
If it returns false, the AJAX call and the defaultstart
callback will not be executed.start <Function>
beforeEnd <Function>
If it returns false, the defaultend
callback will not be executed.end <Function>
Returns:
xhr The jqXHR object or null if the iframe method was used to send a form
- Type
- jqXHR