【发布时间】:2016-09-06 12:16:40
【问题描述】:
在我的代码中,我试图像这样连接我的 jQuery 变量
user_username = $(this).parent().parent().children('td:nth-child(15)').text(); //value is m
但是这行得通
$('#photo').attr('src', "{{ route('account.image', ['filename' => 'm.jpg']) }}"); // the image is showing
虽然没有
$('#photo').attr('src', "{{ route('account.image', ['filename' => '"+user_username+".jpg']) }}"); // the image is not showing
注意:我正在使用 laravel 显示图像
问题是当我提醒我的字符串时,它返回 %22+user_username+%22.jpg 而不是 m.jpg
【问题讨论】:
-
“不工作”是什么意思?
-
user_username有价值吗? -
是的,值为m
-
检查 img
src是否已更改为您的值。 -
再次:“不工作”是什么意思?价值是否丢失?语法错误?有什么事吗?
标签: jquery laravel variables concatenation