0
我通過$ .ajax從數據庫獲取數據。但我如何創建一個鏈接?Symfony2使用數據庫參數創建一個動態鏈接
這是我的Ajax調用,結果作品:
var $resultDepartment = $('#resultDepartment');
$.ajax({
type: "post",
url: url2,
data: "locationid=" + locationid,
dataType: "json",
success: function (resp) {
for (var i = 0; i < resp.length; i++) {
var $link = "{{ path('_niederlassung', {filiale: resp[i].bezeichnung}) }}";
console.log($link);
$resultDepartment.html("Your Department:<br><br>" + resp[i].bezeichnung) + "<br><br><a href='" + $link + "'>weiter zur Filiale</a>";
}
}
});
當我把{{路徑( '_ niederlassung',{分公司: 'exampledepartment'})}}到樹枝,它會被渲染完美並且工作完美。
在這裏,我向您展示的路線:
_niederlassung:
path: /niederlassung/{filiale}
defaults: { _controller: MbsNiederlassungBundle:Default:index, filiale: "all" }