vendredi 2 juin 2017

JavaScript $.post() not working with Laravel 5.4

I am trying to use JavaScript $.post() function in my Laravel project but it does not work.

Following is my JavaScript function

<script>

    function edit_city(id){
    //window.location.href = "editcity/"+id;
    var url= '' + ' /' +id;

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

This is my route:

Route::post('editcity/{city_id}', function () {
    return "view";
});

The page does not give any response. It does not show any error as well. I tired the following JavaScript and it worked fine.

<script>

    function edit_city(id){
    window.location.href = "editcity/"+id;
    }
    </script>



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

Aucun commentaire:

Enregistrer un commentaire