Ver Mensaje Individual
  #9 (permalink)  
Antiguo 14/03/2014, 12:50
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 8 meses
Puntos: 10
Respuesta: Enviar datos recogidos de json

Cita:
Iniciado por Alexis88 Ver Mensaje
Aparentemente, debería funcionar de esa forma. Inténtalo y nos dices cómo te fue.

Saludos

Alexis me da error que no están definidos los item:


Código Javascript:
Ver original
  1. var id_aviso = $('#id_aviso') .val();
  2.  
  3.   $.ajax({
  4.              type: "GET",
  5.              url: "edit-total.php?tabla=1&id_aviso=" +id_aviso,
  6.              dataType: "json",
  7.       beforeSend:function(objeto){
  8.              $('#carga').css({display:'block'});
  9.              },
  10.              complete:function(){
  11.              $('#carga').css('display','none');
  12.              },
  13.            success: function(data){
  14.       var html_user ='' ;
  15.     if(data.length > 0){
  16.      $.each(data, function(i,item){
  17.  
  18.              html_user += '<td >'+item.descuento+'</td>';
  19.              html_user += '<td >'+item.pvp_total+'</td>';
  20.              html_user += '<td >'+item.iva+'</td>';
  21.              html_user += '<td >'+item.total+'</td>';
  22.  
  23.  
  24.  
  25.               });
  26.              
  27.             }
  28.  
  29.         }
  30.                
  31.  });
  32.  
  33.  
  34.     var dataString = 'descuento='+item.descuento+'&pvp_total='+item.pvp_total+'&iva='+item.iva+'&total='+item.total;
  35.          
  36.  
  37.                     $.ajax({
  38.                     type: "POST",
  39.                     url: "insertar.php",
  40.                     data: dataString,
  41.                     beforeSend:function(objeto){
  42.                     $('#carga').css({display:'block'});
  43.                     },
  44.                     complete:function(){
  45.                     $('#carga').css('display','none');
  46.                     },
  47.                     success: function(data) {
  48.  
  49.             }
  50.         });