• Topic
  • Discussion
  • OATWikiWeb.OATDOCajax2(Last) -- Owiki? , 2016-08-19 14:58:49 Edit owiki 2016-08-19 14:58:49

    ajax2.js

    Provides basic Asynchronous XML (AJAX) routines. (also see soap.js for simplified SOAP routines.)

    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.

    Functions

    OAT.AJAX.[METHOD](url, data, callback, options)

    Sends an HTTP request to a pageurl. Valid METHOD names are:

    • GET
    • POST
    • SOAP
    • PUT
    • MKCOL
    • PROPFIND
    • 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:
      • type - response format, one ofTYPE_constants
      • auth - authorization type, one ofAUTH_constants
      • async - bool
      • noSecurityCookie - bool, forbids sending a security cookie & corresponding GET parameter
      • user ,password - credentials for http authorization
      • headers - JS object containing additional headers to be sent
      • onerror - callback to be executed when error occurs
      • onstart - callback to be executed when call launches
      • onend - callback to be executed when call finishes, regardless of success or error condition To prevent JavaScript hijacking attacks, web application authors are encouraged to use some of OAT's built-in countermeasures .

    OAT.AJAX.abortAll()

    Cancels all pending requests.

    Properties

    OAT.AJAX.startRef

    Function to be executed when a request is being sent.

    OAT.AJAX.endRef

    Function to be executed when all requests are satisfied (or canceled).

    Constants

    OAT.AJAX.AUTH_NONE

    When auth option of request is set to this constant, no authentication will be performed.

    OAT.AJAX.AUTH_BASIC

    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 rfc2617 ).

    OAT.AJAX.AUTH_DIGEST

    Auth digest scheme is not yet supported.

    OAT.AJAX.TYPE_TEXT

    When type option of request is set to this value, request will be returned as plain text.

    OAT.AJAX.TYPE_XML

    When type option of request is set to this value, request will be returned as XML document.

    Messages

    OAT.MSG.AJAX_START

    When AJAX request is sent, OAT emits this message containing URL of the request and appropriate message code.

    OAT.MSG.AJAX_ERROR

    When AJAX request is unsuccessful, OAT emits this message containing request object and appropriate message code.

    Example

    var options = {
            user:"username",
            password:"top_secret",
            auth:OAT.AJAX.AUTH_BASIC,
            onerror:function(request) { alert(request.getStatus()); }
    }
    var callback = function(data) { alert(data); };
    OAT.AJAX.GET("/myfile.xml", false, callback, options);
    

    Referenced by...