[英]Error Ajax , Jquery Uncaught SyntaxError: missing ) after argument list
i'm getting syntax error like this我收到这样的语法错误
Uncaught SyntaxError: missing ) after argument list
and this is the code这是代码
$(document).ready(function(){
$('#jk_id').on('change',function(){
let id = $this.val();
$('#kk_id').empty();
$('#kk_id').append('<option value="0" selected disabled>--- Pilih Komponen Kegiatan ---</option>');
$.ajax({
type:'GET',
url:'admin/pengajuan/create1/' + id,
success: function(response) {
var response = JSON.parse(response);
console.log(response);
$('#kk_id').empty();
$('#kk_id').append('<option value="0" selected disabled>--- Pilih Komponen Kegiatan ---</option>');
response.forEach(element => {
$('#kk_id').append('<option value ="${element['id']}">${element['name']}</option>');
});
}
});
});
});
i'm new on Jquery............................................................................我是 Jquery 的新手...................................... ...................................
Replace代替
'<option value ="${element['id']}">${element['name']}</option>'
on the 6th line up with 6日与
`<option value ="${element['id']}">${element['name']}</option>`
Notice I used the grave accent ( ` ) character instead of single-quotes ( ' ) at the beggining and end.请注意,我在开头和结尾使用了重音符号 ( ` ) 而不是单引号 ( ' )。 This will allow you to use template literals.
这将允许您使用模板文字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.