Component Recite_Ajax

This components contains methods for performing Ajax requests in the Recite CMS Control Panel.

Method: Recite_Ajax.Ajax

<static> Recite_Ajax.Ajax(url, method, data, fnSuccess, fnError)

Perform an Ajax request. This will automatically interpret any returned events or messages from PHP action handlers (unless you use your own success and/or error callbacks

Recite_Ajax.Ajax(
    Recite.GetUrl('assets:asset:import'),
    'post',
    {
        'foo' : 'bar'
    }
);
  • Parameters:

    • String url - The URL to send the request to

    • String method - Optional - The request method to use (get or post)

    • Object data - Optional - Any additional data to send with the request

    • Function fnSuccess - Optional - Callback function when request completes (request may be HTTP error)

    • Function fnError - Optional - Callback function when request does not complete (e.g. if network down)

  • Returns: Void

Method: Recite_Ajax.Error

<static> Recite_Ajax.Error(xhr, textStatus, errorThrown)

This is the callback method for a failed Ajax request. It automatically processes any included events and status messages. You can chain this callback to your own Ajax handler by simply called Recite_Ajax.Success() at the end of your handler (remembering to include the original parameters). This will automatically display a status message indicating that an error occurred.

Recite_Ajax.Post(
    Recite.GetUrl('assets:asset:import'),
    {
        'foo' : 'bar'
    },
    null,
    function(xhr, textStatus, errorThrown)
    {
        // do something, then chain to error
        Recite_Ajax.Error(xhr, textStatus, errorThrown);
    }
);
  • Parameters:

    • XMLHttpRequest xhr - The transport object

    • String textStatus - The text status message

    • Mixed errorThrown - The error that occurred

  • Returns: Void

Method: Recite_Ajax.Get

<static> Recite_Ajax.Get(url, data, fnSuccess, fnError)

Wrapper function for calling Recite_Ajax.Ajax() as a get request

Recite_Ajax.Get(
    Recite.GetUrl('assets:asset:import')
);
  • Parameters:

    • String url - The URL to send the request to

    • Object data - Optional - Any additional data to send with the request

    • Function fnSuccess - Optional - Callback function when request completes (request may be HTTP error)

    • Function fnError - Optional - Callback function when request does not complete (e.g. if network down)

  • Returns: Void

  • See:

    • Recite_Ajax.Ajax

Method: Recite_Ajax.Post

<static> Recite_Ajax.Post(url, data, fnSuccess, fnError)

Wrapper function for calling Recite_Ajax.Ajax() as a post request

Recite_Ajax.Post(
    Recite.GetUrl('assets:asset:import'),
    {
        'foo' : 'bar'
    }
);
  • Parameters:

    • String url - The URL to send the request to

    • Object data - Optional - Any additional data to send with the request

    • Function fnSuccess - Optional - Callback function when request completes (request may be HTTP error)

    • Function fnError - Optional - Callback function when request does not complete (e.g. if network down)

  • Returns: Void

  • See:

    • Recite_Ajax.Ajax

Method: Recite_Ajax.Success

<static> Recite_Ajax.Success(data)

This is the callback method for a successful Ajax request. It automatically processes any included events and status messages. You can chain this callback to your own Ajax handler by simply called Recite_Ajax.Success() at the end of your handler (remembering to include the original response JSON data)

Recite_Ajax.Post(
    Recite.GetUrl('assets:asset:import'),
    {
        'foo' : 'bar'
    },
    function(data)
    {
        // do something, then chain to success
        Recite_Ajax.Success(data);
    }
);
  • Parameters:

    • String data - The data returned from an Ajax request

  • Returns: Void