Namespace: Ajax

TDI. Ajax

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

Request
Response

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 the elm 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 call
action The same as href
data-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-element
data-related-ancestor A selector pointing to a related parent element. This element gets notified when the Ajax call starts/ends
data-confirm A confirmation message. Use when the user should be able to stop the Ajax call
disabled The Ajax call does not start if the element has the disabled atribute set
class="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 default start callback will not be executed.
start <Function>
beforeEnd <Function> If it returns false, the default end 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