Semantic-Org/Semantic-UI · warning

You are using legacy API success callback names

Error message

You are using legacy API success callback names

What it means

This error is logged by the API module's get.settings() function (api.js:716-748) when the user's beforeSend callback returns a settings object that still uses the legacy callback names success, failure, or complete instead of the current onSuccess, onFailure, onComplete. The module detects these legacy properties, logs the error for each, and migrates them to the new names automatically. This is a deprecation warning, not a functional failure.

Source

Thrown at src/definitions/behaviors/api.js:1131

  // failed JSON success test
  onFailure   : function(response, $module) {},

  // server error
  onError     : function(errorMessage, $module) {},

  // request aborted
  onAbort     : function(errorMessage, $module) {},

  successTest : false,

  // errors
  error : {
    beforeSend        : 'The before send function has aborted the request',
    error             : 'There was an error with your request',
    exitConditions    : 'API Request Aborted. Exit conditions met',
    JSONParse         : 'JSON could not be parsed during error handling',
    legacyParameters  : 'You are using legacy API success callback names',
    method            : 'The method you called is not defined',
    missingAction     : 'API action used but no url was defined',
    missingSerialize  : 'jquery-serialize-object is required to add form data to an existing data object',
    missingURL        : 'No URL specified for api event',
    noReturnedValue   : 'The beforeSend callback must return a settings object, beforeSend ignored.',
    noStorage         : 'Caching responses locally requires session storage',
    parseError        : 'There was an error parsing your request',
    requiredParameter : 'Missing a required URL parameter: ',
    statusMessage     : 'Server gave an error: ',
    timeout           : 'Your request timed out'
  },

  regExp  : {
    required : /\{\$*[A-z0-9]+\}/g,
    optional : /\{\/\$*[A-z0-9]+\}/g,
  },

  className: {

View on GitHub (pinned to 597843ab84)

Solutions

  1. Rename success to onSuccess, failure to onFailure, and complete to onComplete in the settings returned by beforeSend.
  2. Move callbacks to the top-level settings object instead of returning them from beforeSend.

Example fix

// before
$('.api-element').api({
  beforeSend: function(settings) {
    settings.success = function(response) { /* ... */ };
    settings.failure = function(response) { /* ... */ };
    return settings;
  }
});

// after
$('.api-element').api({
  beforeSend: function(settings) {
    settings.onSuccess = function(response) { /* ... */ };
    settings.onFailure = function(response) { /* ... */ };
    return settings;
  }
});
Defensive patterns

Strategy: validation

Validate before calling

// Validate beforeSend return object for legacy property names
$('.el').api({
  beforeSend: function(settings) {
    // Check for and migrate legacy callback names
    if (settings.success) { settings.onSuccess = settings.success; delete settings.success; }
    if (settings.failure) { settings.onFailure = settings.failure; delete settings.failure; }
    if (settings.complete) { settings.onComplete = settings.complete; delete settings.complete; }
    return settings;
  }
});

Type guard

// Type guard: check for legacy callback names
function hasLegacyCallbacks(settings) {
  return settings && (settings.success !== undefined || settings.failure !== undefined || settings.complete !== undefined);
}

Prevention

When it happens

Trigger: Providing a beforeSend callback that returns an object with .success, .failure, or .complete properties instead of .onSuccess, .onFailure, or .onComplete. This commonly occurs when copying old jQuery $.ajax() configuration patterns into the API module's beforeSend.

Common situations: Migrating from an older version of Semantic UI or Fomantic-UI that used legacy callback names. Developers familiar with jQuery's native $.ajax success/error/complete API using those names in the API module's settings. Copy-pasting AJAX code samples from jQuery tutorials.

Related errors


AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13). Data as JSON: /api/errors/0d7b36af6432abf9. Report an issue: GitHub.