<docbook><section><title>OATDOCajax2</title><para> </para>
<title> ajax2.js</title> ajax2.js
<para>Provides basic Asynchronous XML (AJAX) routines.
 (also see <ulink url="OATDOCsoap">soap.js</ulink> for simplified SOAP routines.)</para>
<emphasis>THIS IS THE NEW API VERSION.
 YOU CAN STILL USE THE OLD ONE ( ajax.js ), BUT IT IS OBSOLETE AND UNSUPPORTED.
  YOU SHOULD SWITCH TO THIS INTERFACE ASAP.</emphasis><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Functions</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.AJAX.[METHOD](url, data, callback, options)</bridgehead>
<para>Sends an HTTP request to a pageurl.
 Valid METHOD names are:</para>
<itemizedlist mark="bullet" spacing="compact"><listitem>GET </listitem>
<listitem>POST </listitem>
<listitem>SOAP </listitem>
<listitem>PUT </listitem>
<listitem>MKCOL </listitem>
<listitem>PROPFIND </listitem>
<listitem>PROPPATCH Data to be contained in request are specified in data.
 When response arrives,callback(response)will be executed.
 You may specify the following options: <itemizedlist mark="bullet" spacing="compact"><listitem><emphasis>type</emphasis> - response format, one ofTYPE_constants </listitem>
<listitem><emphasis>auth</emphasis> - authorization type, one ofAUTH_constants </listitem>
<listitem><emphasis>async</emphasis> - bool </listitem>
<listitem><emphasis>noSecurityCookie</emphasis> - bool, forbids sending a security cookie &amp; corresponding GET parameter </listitem>
<listitem><emphasis>user</emphasis> ,password - credentials for http authorization </listitem>
<listitem><emphasis>headers</emphasis> - JS object containing additional headers to be sent </listitem>
<listitem><emphasis>onerror</emphasis> - callback to be executed when error occurs </listitem>
<listitem><emphasis>onstart</emphasis> - callback to be executed when call launches </listitem>
<listitem><emphasis>onend</emphasis> - callback to be executed when call finishes, regardless of success or error condition <emphasis>To prevent <ulink url="JavaScript">JavaScript</ulink> hijacking attacks, web application authors are encouraged to use some of OAT&#39;s built-in countermeasures .</emphasis></listitem>
</itemizedlist></listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.AJAX.abortAll()</bridgehead>
<para>Cancels all pending requests.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Properties</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.AJAX.startRef</bridgehead>
<para>Function to be executed when a request is being sent.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.AJAX.endRef</bridgehead>
<para>Function to be executed when all requests are satisfied (or canceled).</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Constants</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.AJAX.AUTH_NONE</bridgehead>
<para>When auth option of request is set to this constant, no authentication will be performed.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.AJAX.AUTH_BASIC</bridgehead>
<para>When auth option of request is set to this constant, request header with authentication data will be appended using auth basic scheme (as described in <ulink url="http://www.ietf.org/rfc/rfc2617.txt">rfc2617</ulink> ).</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.AJAX.AUTH_DIGEST</bridgehead>
<para>Auth digest scheme is not yet supported.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.AJAX.TYPE_TEXT</bridgehead>
<para>When type option of request is set to this value, request will be returned as plain text.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.AJAX.TYPE_XML</bridgehead>
<para>When type option of request is set to this value, request will be returned as XML document.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Messages</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.MSG.AJAX_START</bridgehead>
<para>When AJAX request is sent, OAT emits this message containing URL of the request and appropriate message code.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.MSG.AJAX_ERROR</bridgehead>
<para>When AJAX request is unsuccessful, OAT emits this message containing request object and appropriate message code.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Example</bridgehead>
<programlisting>var options = {
        user:&quot;username&quot;,
        password:&quot;top_secret&quot;,
        auth:OAT.AJAX.AUTH_BASIC,
        onerror:function(request) { alert(request.getStatus()); }
}
var callback = function(data) { alert(data); };
OAT.AJAX.GET(&quot;/myfile.xml&quot;, false, callback, options);
</programlisting><para> <ulink url="CategoryDocumentation">CategoryDocumentation</ulink> <ulink url="CategoryOAT">CategoryOAT</ulink> <ulink url="CategoryOpenSource">CategoryOpenSource</ulink></para>
</section></docbook>