0

Face problem when writing PHP syntax in javascript syntax.

var id = $("#data-1").val();
var url = '<?= base_url('home/alone/'); ?>.'id'';
console.log(url);

I need to place the id at the end of url. But my code is not working. What is wrong? Thank you in advance.

1
  • Too many single quotes and use + in JS to concatenate Commented Mar 15, 2022 at 7:38

1 Answer 1

2

use " instead of ' like this:

var id = $("#data-1").val();
var url = "<?= base_url('home/alone/'); ?>" + id;
console.log(url)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.