Report an issue
Class

CKEDITOR.ajax

class singleton

Ajax methods for data loading.

Filtering

Methods

  • load( url, [ callback ] ) → String

    Loads data from a URL as plain text.

    // Load data synchronously.
    var data = CKEDITOR.ajax.load( 'somedata.txt' );
    alert( data );
    
    // Load data asynchronously.
    var data = CKEDITOR.ajax.load( 'somedata.txt', function( data ) {
        alert( data );
    } );
    

    Parameters

    url : String

    The URL from which the data is loaded.

    [ callback ] : Function

    A callback function to be called on data load. If not provided, the data will be loaded synchronously.

    Returns

    String

    The loaded data. For asynchronous requests, an empty string. For invalid requests, null.

  • loadXml( url, [ callback ] ) → xml

    Loads data from a URL as XML.

    // Load XML synchronously.
    var xml = CKEDITOR.ajax.loadXml( 'somedata.xml' );
    alert( xml.getInnerXml( '//' ) );
    
    // Load XML asynchronously.
    var data = CKEDITOR.ajax.loadXml( 'somedata.xml', function( xml ) {
        alert( xml.getInnerXml( '//' ) );
    } );
    

    Parameters

    url : String

    The URL from which the data is loaded.

    [ callback ] : Function

    A callback function to be called on data load. If not provided, the data will be loaded synchronously.

    Returns

    xml

    An XML object storing the loaded data. For asynchronous requests, an empty string. For invalid requests, null.

  • post( url, data, [ contentType ], [ callback ] )

    since 4.4

    Creates an asynchronous POST XMLHttpRequest of the given url, data and optional contentType. Once the request is done, regardless if it is successful or not, the callback is called with XMLHttpRequest#responseText or null as an argument.

    CKEDITOR.ajax.post( 'url/post.php', 'foo=bar', null, function( data ) {
        console.log( data );
    } );
    
    CKEDITOR.ajax.post( 'url/post.php', JSON.stringify( { foo: 'bar' } ), 'application/json', function( data ) {
        console.log( data );
    } );
    

    Parameters

    url : String

    The URL of the request.

    data : String | Object | Array

    Data passed to XMLHttpRequest#send.

    [ contentType ] : String

    The value of the Content-type header.

    Defaults to 'application/x-www-form-urlencoded; charset=UTF-8'

    [ callback ] : Function

    A callback executed asynchronously with XMLHttpRequest#responseText or null as an argument, depending on the status of the request.