Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
Tabla de datos - éxito ajax

Cuando agrego la función de éxito, DataTable no llena automáticamente las filas en la tabla. Cuando elimino la función de éxito, todo está bien y la tabla de datos completa correctamente los datos en la tabla. Quiero capturar en respuesta usando el mensaje getAccessMessageWithStatus por estado, pero si lo hago como esta tabla de datos, no hay filas de relleno. ¿Como puedo hacer eso?

 $('#' + datatableName).DataTable({ destroy: true, 'bProcessing': false, 'bServerSide': true, 'ajax': { 'url': URL, 'data': filters, beforeSend: function() { loader.popup('show'); }, success: function(response) { getAccessMessageWithStatus(response); }, complete: function() { $listContainer.show(); $containerChoiseColumnsFilter.show(); $(".containerRaportButtons").show(); getLastSearches(); getUses(); loader.popup('hide'); } }, 'sServerMethod': "POST", 'columns': columns, 'order': order, 'responsive': true });

Respuestas:

 success: function(response) { getAccessMessageWithStatus(response); },

O:

 "dataSrc": function(response) { if (response.status == false) { alert(response.msg); return []; } return response.aaData; },
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Remover ";" después del nombre de la función en el código.

 success: function (response) { getAccessMessageWithStatus(response) },
over 4 years ago · Santiago Trujillo Report

0

Hay un evento de DatatTable llamado 'xhr.dt' . Puedes usarlo de esa manera.

 $('#' + datatableName).on('xhr.dt', function(e, settings, json, xhr){ getAccessMessageWithStatus(json); }).DataTable({ destroy: true, 'bProcessing': false, 'bServerSide': true, 'ajax': { 'url': URL, 'data': filters, beforeSend: function () { loader.popup('show'); }, complete: function () { $listContainer.show(); $containerChoiseColumnsFilter.show(); $(".containerRaportButtons").show(); getLastSearches(); getUses(); loader.popup('hide'); } } });

No debe usar el éxito del atributo ajax porque sobrescribirá la función de éxito de DataTable. Vea este fragmento de código de query.dataTables.js

 "success": function (json) { var error = json.error || json.sError; if ( error ) { _fnLog( oSettings, 0, error ); } oSettings.json = json; callback( json ); }

Puede notar que tienen una devolución de llamada dentro de esta función. Esta devolución de llamada activa la función _fnCallbackFire y esta llamada al evento xhr.dt

Para obtener más información, vaya a esta página https://datatables.net/reference/event/xhr

over 4 years ago · Santiago Trujillo Report

0

Puedes usarlo de esta manera:

 "complete": function (json, type) { //type return "success" or "parsererror" if (type == "parsererror") { alert("parsererror"); } ... }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!