Return detail table using AJAX

0

I am designing a dynamic application, that is, a store has different packages with prices. There are 7 taps with a barrel from which two and a half liter measures are taken to sell:

$.ajax({
	  
            type: "POST",
            url: "../gestionweb/views/modules/venta/procesoventa.php",
                data:{"accion":"lcanillas"},
      

            error: function(){
                alert("error petición ajax");
            },
            success:function(data)
            {
       
                   $.each(JSON.parse(data), function (index, item) {
               medidas=Obtenerprecios(item.idbarril);
                    $.each(medidas,function (index,item){
                      var fila='<tr>'+
    
    '<td>'+item.descripcion+'</td>'+
    '<td>'+item.precio+'</td></tr>';
                     cm=cm+fila;   
                    });
                 
         var contenido='<div class="col-sm-4" > '+
         '<div class="panel panel-danger">'+
          '<div class="panel-heading">CANILLA '+item.idcanilla+'</div>'+
          '<div class="panel-body">'+
        '<table class="canilla">'+
   ' <thead>'+
    '<th></th>'+
    '<th>Valor</th>'+
    '<th>Accion</th>'+
    '</thead>'+
    '<tbody>'+
    '<tr>'+
    '<td>Estado</td>'+
    '<td>'+item.estado+'</td>'+
    '</tr>'+cm
    +'<td><input type="button" id="Confirmar" value="Confirmar" class="btn btn-primary" /></td>'
  
  
   ' </tbody>'+
  '</table>'+
      '     </div></div></div> ' +
      '  </div>';
      $(contenido).appendTo("#canilla1");
      cm="";
                });

                }
 
});

With the above code I can see the taps well, but the fact is that each tap is associated with an existing measurement in another table. Then as you will see inside each one I call another function, and doing a console.log if I get the prices accordingly but it shows me undefined:

 function Obtenerprecios(idbarril) {
 return $.ajax({
	  
            type: "POST",
            url: "../gestionweb/views/modules/venta/procesoventa.php",
                data:{"accion":"medidas","idb":idbarril},
      

            error: function(){
                alert("error petición ajax");
            },
            success:function(data)
            {

            }
            });}

I really do not know what I'm doing wrong or how else to return the data of the function. the return ajax returns Object {readyState: 1, getResponseHeader: getResponseHeader (), getAllResponseHeaders: getAllResponseHeaders (), setRequestHeader: setRequestHeader (), overrideMimeType: overrideMimeType (), statusCode: statusCode (), abort: abort (), state: state (), always: always (), catch: catch (), ...} indexventa.js: 25: 14 And in responseText are the data but how could I read it?

    
asked by Caruso 09.11.2018 в 13:49
source

0 answers