jeudi 2 novembre 2017

How to add a javascript variable as action parameter in Laravel form

I was trying add a js variable as my action parameter where that variable varies for every button a form will be created and will be sent to a bootstrap modal-body(initially modal-body is blank). Here is the js code i was trying to assign to modal-body html

$('.postComment').click(function(e){
    e.preventDefault;
    var id = $(this).attr('id'); //this is the id suppose:id='1234abcd'

    var data =  ''+
                ''+
                ''+
                '';
    $('#comment').modal();
    $('#comment').on('shown.bs.modal', function(){
        $('#comment .modal-body').html(data);
    });
    $("#comment").on('hidden.bs.modal', function(){
            $('#comment .modal-body').html('');
        });
});

When clicking on comment button in the form action appears like this

action="/post/comment/+id+"

But expected is

action="/post/comment/1234abcd"

Am I missing something? or doing in wrong way?



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

1 commentaire: