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 Answer 1
use " instead of ' like this:
var id = $("#data-1").val();
var url = "<?= base_url('home/alone/'); ?>" + id;
console.log(url)
answered Mar 15, 2022 at 7:46
Milad Elyasi
9605 silver badges15 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default
+in JS to concatenate