lundi 25 février 2019

How to pass data from controller to view in laravel?

I need to pass data from controller to view this is my code :

Controller :

function requete()
{
    $id = Str::random();
    echo json_encode($id);  
    return view('Demo.requete');
}

View :

$(document).ready(function() {   
    $.ajax({
        url: "",
        method: "get",
        data: data
        dataType: "json",
        success: function(data)
        {
            $('#code').html(data); //nothing happens here
        }
    });
});

The data is displaying on top of the page not in the '#code' section and i get this error :

result of request



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GIsUCL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire