Takami Takami - 1 year ago 58
Javascript Question

Can't make this work

How can i change variable value?, i tried using "Promises" but it doesn't work it gaves me an error, i'm trying to load a data on a table

/* Formating function for row details */
function fnFormatDetails(oTable, nTr) {
var aData = oTable.fnGetData(nTr);
var sOut ='';
$.post("http://localhost:3000/almuerzo/findIng", {
nombre: aData[1]},
function(data, status){
sOut = '<ul>';
sOut += data.nombre;
sOut += '</ul>';
return sOut;

As i said when i try to use promises de "datable.tabletools plugin" fails, said that there's an error on "show"

Answer Source

You can't use

return sOut;

Outside the callback function.

sOut would always be '' in your example.