Categories

ep.ajax()

Categories: Low-Level Interface

ep.ajax( options )

Plugin: ep.ajaxTransport

Description: Perform an asynchronous file upload with HTTP (Ajax).

  • ep.ajax( options )

    version added: 6.12.0

    options   A set of key/value pairs that configure the Ajax request. All settings are optional.

The ep.ajax() function is a modified alias of jQuery.ajax() and supports all options of jQuery.ajax().

This method provides file upload with AJAX. File uploads are always asynchrony the async options isn't editable. To upload files with ep.ajax() us the additional options file, fileSizeMax, fileMimeAccept and progress.

New API standard in 6.14.0

For AJAX use deferred object methods instead of setting success, error, complete and progress methods as arguments.

Properties to methods:

  • success => .done()
  • error => .fail()
  • complete => .always()
  • progress => .progress()
  • Upload files with ajax on change.

    HTML:
    <input id="upload" type="file" multiple="true" name="NewFile" />
    
    Code:
    $('#upload').on( 'change', function(event){
        ep.ajax({
            file:           this,
            fileSizeMax:    2097152,
            fileMimeAccept: 'image/*',
            dataType:       'json'
        })
        .progress(function( event, statusText, jqXHR ){
            // added in verison 6.14.0
        })
        .done(function( jsonData, statusText, jqXHR ){
    
        })
        .fail(function( jqXHR, statusText, errorThrown ){
    
        })
    });
    
    
  • file

    version added: 6.12.0

    An input element of type file, which contains the file(s) to upload (only in connection with dataType 'json').

  • fileSizeMax

    version added: 6.12.0

    A number of file size limit (bytes).

    Default: 2097152

  • fileMimeAccept

    version added: 6.12.0

    A string containing one or more mime types / mime type groups.

  • progress

    version added: 6.12.0

    An event method which called on file upload progress. Receives event, statusText and jqXHR as arguments.

ep.ajax( options )

Plugin: ep.ajax

Description: Perform an asynchronous HTTP (Ajax) request.

  • ep.ajax( options )

    version added: 6.11.0

    options   A set of key/value pairs that configure the Ajax request. All settings are optional.

The ep.ajax() function is a modified alias of jQuery.ajax().

If dataType json, ep.ajax() add "Accept", "text/x-json" to the requestHeader and set the url to ep.config.baseUrl. If dataType json and the response contains the Error object, ep.ajax() interprets the request as error.

This plugin setup the default ajax-type of jQuery.ajax() and ep.ajax() to get. To change this add a "type: post" to the parameters.

To do a sync requests instead of async just add "async: false" to the parameters.

To prevent browser caching of the request use the parameter: "cache: false". The default behaviour is "cache: true".

New API standard in 6.14.0

For AJAX use deferred object methods instead of setting success, error and complete methods as arguments.

Properties to methods:

  • success => .done()
  • error => .fail()
  • complete => .always()
  • Perform an ajax request.

    Code:
    ep.ajax({
        data: {
            ObjectID: 5,
            ViewAction : 'JSONGet'
        },
        cache: false,
        type: "post",
        async: false,
        dataType: "json",
        success:
    })
    .done(function( jsonData ){
    
    });