jeudi 1 juin 2017

Laravel 5.4 : how to pass variable to route with JavaScript

I want to pass a variable 'id' to my route with JavaScript. Following is my JavaScript code:

    <script>
    function edit_city(id){

    $.post("", {id: id}, function(page_response)
    {
    alert(page_response);
    });
    }
   </script>

This is my route:

Route::post('edit_city/{id}', function ($id) {
    echo $id;
});

Please Help. i don't know where I am making mistake.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire