简体   繁体   English

用ajax调用twig函数(渲染)

[英]call a twig function (render) with ajax

I have in my template a twig call : 我的模板中有一个树枝调用:

{{ render(controller( 'MyApplicationBundle:Application:timeline', { 'number': '0-10' } )) }}

So, with this line, i call my action timeline , retrieve the last 10 posts of my timeline, call my view timeline.html.twig and display them. 因此,在这一行中,我将其命名为动作timeline ,检索该timeline的最后10条帖子,然后调用我的视图timeline.html.twig并显示它们。

I need, when the user scroll to the bottom of the page for example, re-call this line and change the parameter number (with 10-20) for retrieve other posts and re-display them. 我需要,例如,当用户滚动到页面底部时,重新调用此行并更改参数编号(使用10-20)以检索其他帖子并重新显示它们。

My question, how can i call this line (render(controller))) with ajax and display the response on my page ? 我的问题是,如何用ajax调用此行(render(controller)))并在页面上显示响应?

Why do you need to call render(controller) from js? 为什么需要从js调用render(controller)? You can simply call MyApplicationBundle:Application:timeline by his url? 您可以通过URL直接调用MyApplicationBundle:Application:timeline What the problem? 什么问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM