简体   繁体   中英

How to print arrays in Laravel with innerHTML

I recieve an array with AjaxPetitions Array[0],Array 1 , Array[2] and recieve the information correctly.

$.ajax({
                url:'obtenersubastas',
                dataType:'json',
                type:'get',
                cache:true,
                success:  function (response) {
                    $(response).each(function(index,value)  {
                            console.log(response[index].nombre);
                            console.log(response[index].descripcion);
                            console.log(response[index].cant_actual);
                            console.log(response[index].images);
                            console.log(response[index].data_final);
                            console.log(response[index].id);
                    });

                },              
        });

I need to send this information to a class called .nombre html , could anyone helps to me ?

UPDATE

with append I have a problem , i need to follow a style in the page and the result is this.

在此处输入图片说明

You can use $('.nombre').html() to add your values in the selector element.

Try this code

 $.ajax({
            url:'obtenersubastas',
            dataType:'json',
            type:'get',
            cache:true,
            success:  function (response) {
                $(response).each(function(index,value)  {
                       $('.nombre').append('<p>Nombre :' +response[index].nombre +' descripcion: '+ response[index].descripcion + ' cant_actual: '+response[index].cant_actual +' images : '+ response[index].images +' data_final: '+ response[index].data_final +' id :'+ response[index].id+'</p>');
                });

            },              
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM