$.ajax 経由でデータベースからデータを取得しました。しかし、どうすればリンクを作成できますか?
これは私の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>";
}
}
});
{{ path('_niederlassung', {filiale: 'exampledepartment'}) }} を小枝に配置すると、完璧にレンダリングされ、完璧に機能します。
ここで私はあなたにルートを示します:
_niederlassung:
path: /niederlassung/{filiale}
defaults: { _controller: MbsNiederlassungBundle:Default:index, filiale: "all" }