I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that? This is my jquery code: $('.view-all-content').click(function() { $.post("/callajax", { 'action': 'get_data_from_view', }, function(data) { console.log(data) // if (data == "gg") { // console.log("suc") // } $(".view-all-content-result").html(data); }); }); In my function.php function get_data_from_view(){ $view = \Drupal::service('renderer')->render(views_embed_view('article_list', 'page_5')); //Also i have added foreach echo $view; }