Twig template parameter front and back

/Foreground traverses the array data in the background
$.ajax({
    type: 'GET',
    url: "{{ path('courier_changeSite') }}",
    data: {areaCode:areaCode, company:company},
    async:false,
    success: function(data) {
        $('#id_siteSelect').html("");
        for (var i=0;i<data.length;i++)
        {
            $("#id_siteSelect").append("<option value='" + data[i]['id'] + "'>" + data[i]['siteName'] + "</option>");
        }

    }
});

//js receives the raw tag of the background data   to ensure that the data in the block is not parsed by the template engine.
var address =};
address['0'] = {{ province|json_encode|raw }};
address['1'] = {{ city|json_encode|raw }};
address['2'] = {{ country|json_encode|raw }};

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327000336&siteId=291194637