Return arrangement of views from laravel to ajax

1

I have a method that returns an arrangement of views

$array = [
    'desktop' => view('results-json'),
    'ipad' => view('results-json-ipad'),
]

return $array;

How can I make that arrangement can be rendered in the view if I am accessing it from an ajax? Something like this:

$.ajax({
    url: '...',
    data: { ... },
    success: function(res){
        $('#element').html(res.desktop)
    }
})

Thank you in advance for your help and ideas.

    
asked by Agares 30.10.2018 в 20:07
source

1 answer

1

try this!

$.ajax({
    url: '...',
    data: { ... },
    dataType:json,
    success: function(res){
        $.each( res.desktop, function( key, value ) {
           console.log( key + ": " + value );
       });
    }
})
    
answered by 30.10.2018 / 20:15
source