How AJAX calls work with TWIG

前端 未结 2 2028
名媛妹妹
名媛妹妹 2021-02-02 00:42

I am trying to understand how Twig can load a template through AJAX. From their website, it is clear how to load a template (http://twig.sensiolabs.org/doc/api.html)

<         


        
2条回答
  •  攒了一身酷
    2021-02-02 01:17

    Directly in the template:

    {% if app.request.isXmlHttpRequest() %}
      // code if ajax request
    {% else %}
      // code if not ajax request
    {% endif %}
    

提交回复
热议问题