vendredi 31 juillet 2020

How to pass Js variable through html anchor tag

Here I am trying to pass the id to the controller like this

but the '+val[0]+' is consider as a string in url http://localhost:8000/admin/service/**+val%5B0%5D+**/edit

but the variable looks like +val%5B0%5D+ in URL but I want its value

this is my anchor tag

<a href=""></a>

Below is the full code

$.ajax({
       type:'POST',
       url:'/admin/service/show_list',
       data:{ modality_id: m, center_id: h },
       success:function(data) {
           $("#service-table > tbody").empty();
                var trHTML = '';
                $.each( data.service_list1, function( i, val ) {
                    trHTML +='<tbody><tr id="myTableRow" style="text-align:center;"><td>' + val[0] + '</td><td>' + val[1] + '</td><td><a href="" class="btn btn-default btn-xs" title="Edit Service"><i class="fa fa-pencil"></i></a></td></tr></tbody>';
                });
                $('#service-table').append(trHTML);
                }
       });

But I want to pass the value of that variable in URL so how I am able to do it ??

Advance Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire