CKEditor 4 Documentation

CKEDITOR.ajax

Files

Ajax methods for data loading.

Defined By

Methods

CKEDITOR.ajax
view source
( url, [callback] ) : String
Loads data from a URL as plain text. ...

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 (optional)

    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.

CKEDITOR.ajax
view source
( url, [callback] ) : CKEDITOR.xml
Loads data from a URL as 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 (optional)

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

Returns

  • CKEDITOR.xml

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

CKEDITOR.ajax
view source
( url, data, [contentType], [callback] )
Creates an asynchronous POST XMLHttpRequest of the given url, data and optional contentType. ...

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 );
} );

Available since: 4.4

Parameters

  • url : String

    The URL of the request.

  • data : String/Object/Array

    Data passed to XMLHttpRequest#send.

  • contentType : String (optional)

    The value of the Content-type header.

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

  • callback : Function (optional)

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