[英]Symfony2 javascript url
I was using symfony2 and in my javascript file chooselist.js.twig , I need to append something to my html page, and I need to get a path of my image. 我使用的是symfony2,并且在我的javascript文件selectlist.js.twig中 ,我需要在html页面上添加一些内容,并且需要获取图像的路径。 I tried my code like this, but it didn't work.
我像这样尝试了我的代码,但是没有用。
$.ajax({
type: 'POST',
url: 'listmore',
data: btnArr,
success: function(msg){
var ret = $.parseJSON(msg);
var str="";
for(var i=0; i<ret.itemTab.length; i++) {
str +="<a href=\"#\"><li>\
<p id=\"peopleresume"+jid+"_"+ret.itemTab[i]["pid"]+"\">"+ret.itemTab[i]["pname"]+"</p>\
<img src=\"{{asset('img/video.png')}}\"/>\
<div class=\"clear\"></div>\
<div class=\"listInfo\" id="+ret.itemTab[i]["rid"]+">"+ret.itemTab[i]["introduction"]+"</div>\
</li></a>";
}
tempId.find(".ListBlock").append(str);
},
error: function(XmlHttpRequest,textStatus, errorThrown){
alert ("failed! "+XmlHttpRequest.responseText);
}
});
in my code {{asset('img/video.png')}}, it doesn't work. 在我的代码{{asset('img / video.png')}}中,它不起作用。 What should I do to make it work?
我应该怎么做才能使其正常工作?
I think it should be {{ asset('bundles/yourbundle/images/video.png') }} 我认为应该是{{asset('bundles / yourbundle / images / video.png')}}
Furthermore, make sure you installed your assets by running the following command: 此外,请确保通过运行以下命令安装了资产:
php app/console assets:install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.