-1

I have code but any error.

Use of undefined constant id - assumed 'id'

$(document).on('click', '#UpdateForm', function () {
            id = $(this).data('id');
            name = $('#name').val();
            address = $('#address').val();
            country = $('#country').val();
            $.post("{{ URL('peoples.'+id+'.update') }}", {name:name, address:address, country:country, id:id}, function (data){
                //
            });
        });
  • 2
    Change this `"{{ URL('peoples.'+id+'.update') }}"` to this `"{{ URL('peoples."+id+".update') }}"`. I'm pretty much guessing since you've given no explanation whatsoever. – Reinstate Monica Cellio Jun 01 '18 at 14:32
  • Correct, only, does not display information –  Jun 01 '18 at 14:36
  • 1
    Please read **[ask]**, because you are being literally zero help at helping people understand anything, so it's not possible to help you. Hopefully that link will help you improve your question asking abilities. – Reinstate Monica Cellio Jun 01 '18 at 14:41

1 Answers1

0

You can't use javascript variable in php code. Php code run's on the server side and javascript code runs on the client side. You can't ask the browser to run php code. read for more :

Use javascript variable in php code

How can I use a JavaScript variable as a PHP variable?

Alihossein shahabi
  • 4,034
  • 2
  • 33
  • 53