0
我创建eisenhover矩阵,我想要一个按钮来刷新网格中的数据,但我不知道如何传递参数/变量与AJAX。Symfony/PHP7,传递参数与AJAX
/**
* @Route("/articles/list", name="articles_list")
*/
public function showArticlesAction(bool $important = false, bool $urgent = false){
$articles = $this->returnAllArticles();
return $this->render(
'articles/list.html.twig',
array('articles' => $articles,
'important' => $important,
'urgent' => $urgent)
);
}
和脚本
function refreshFunctionName()
{
$.ajax({
type: "POST",
url: "{{ path('articles_list') }}",
data: {'important': true, 'urgent': true},
cache: false,
success: function(data){
$('#list').html(data);
},
error: function(){},
complete: function(){}
});
}
的showArticlesAction始终把默认的数据,如果我尝试使用AJAX使用它,工作正常:
{{ render(controller(
'AppBundle:Articles:showArticles',
{ 'important': true,
'urgent': true}
)) }}