mardi 5 janvier 2016

laravel get object data from jason response giving undefined

i'm using ajax to get data from model by controller every thing is running nice i think and when i check with console.log(response) i get

Object {buyTemps: Object}

and in side the object i found All data inside the array up to now every thing is good

at

    success : function(response) { 
            console.log(response);

       $('#buyItem-table tbody').empty();
        $.each(response,function(index, v){

          //   var v = jQuery.parseJSON(value);

           $('#buyItem-table tbody').append(                                          

                  "<tr><td>"         +  v.buyItemTempId   
                      + "</td><td>"  +  v.itemName    
                      + "</td><td>"  +  v.itemExpire    
                      + "</td><td>"  +  v.buyPrice                          
                      + "</td><td>"  +  v.buyBox   
                      + "</td><td>"  +  v.itemPacking                           
                      + "</td><td>"  +  v.buyQty       
                 + "</td></tr>" );          

           });


    },
    error : function(response) {
      swal("error"); 
    }

at my controller

  $buyId = Input::get('buyId'); 
 $buyTemps = DB::table('vbuytemp')->where('buyId',$buyId)->paginate(10);     
         return Response::json(compact('buyTemps'));

the result all table cell fill with undefined



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1S1QOHP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire