Use variable in messageTop
Use variable in messageTop
silens
Posts: 101Questions: 40Answers: 0
I would like to be able to use the variable to which I make a log in the "success" data ['0']. name_tar in the messageTop: from the pdf
function accionesTG(idT) {
var parametros = {
"idT": idT,
};
tblAcciones = $('#tblAcciones').DataTable({
dom: 'Bfrtip',
buttons: [
{
extend: 'pdfHtml5',
messageTop: "Tarea: "+tareaName //Aqui me gustaria usar `data['0'].nombre_tar`
}
],
"ajax": {
"data": parametros,
"url": "php/Pir/orea.php",
"type": "POST",
"dataSrc": "",
"success": function (data) {
console.log(data['0'].nombre_tar); //Variable que me gustaría usar
},
},
"columns": [
{"data": "nombre_usr" ,"responsivePriority": "6" }
],
});
}
This discussion has been closed.
Answers
Hi @silens ,
You can make it a function, see the
print
button in this example,Cheers,
Colin
Thank you very much for answering, I have read the link you have posted but I still do not understand how you could use the variable of success. I do not understand much of the programming language but I try
This code was from that last example I suggested looking at:
It's using
printCounter
within the function as part of the message.in that case, he declares printcounter before invoking the method. In my case, the variable to use is declared when the function is executed, the variable that I need to use in the button is a field that I can only access in the success. It is a json field that feeds the table. The question is whether I can use a json field that feeds the table in the print button or move to pdf etc
You can get the last JSON response with
ajax.json()
, so you can use that in the same function.