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.
use " instead of ' like this:
var id = $("#data-1").val();
var url = "<?= base_url('home/alone/'); ?>" + id;
console.log(url)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.