I have the following code where when pressing an Item of the table I make a query in Ajax
this returns a result a list of item. I am declaring a Array()
to be able to save this list in the.
$('#table tbody tr> td').click(function() {
var pieza = $(this).closest('tr').find('td:eq(4)').text();
var piezas = [];
$.ajax({
data: {'pieza':pieza},
url: 'JSON/likeJSON.php',
type: 'POST',
cache: false,
success: function (data)
{
//Con la Ayuda de @Sr1871 y @Fran Islas logre poder desplegar el listado.
//Pero lo que ocurre ahora es que si selecciono otra pieza en la tabla,
//el listado no cambia, ya que mi JSON realizo un Where item like '%%'
data = JSON.parse(data);
for (var count = 0; count < data.length; count++) {
piezas.push({
value: count,
text: '' + data[count].pieza + ''
})
}
},
async: false
});
$('#table').editable({
container: 'body',
selector: 'td.Pieza',
title: 'Pieza Nueva',
type: "POST",
source:piezas,
showbuttons: false,
select2: {
width: 200,
placeholder: 'Nueva Pieza',
allowClear: true
},
success: function() {
}
});
})
How can I save the data
in my array in Javascritps to then use this Array()
as source
in my editable method.
With the help of @ Sr1871 and @Fran Islands I will be able to display the list. But what happens now is that if I select another piece this list does not change and my likeJSON see the new data.
I hope you have explained me well