Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8463409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:26:45+00:00 2026-06-10T14:26:45+00:00

I have embed a controller in a template: {% render AcmeUserBundle:User:showUsersList} %} <a onClick=changeStatus({{user.getUserId()}})

  • 0

I have embed a controller in a template:

{% render "AcmeUserBundle:User:showUsersList"} %}

<a onClick="changeStatus({{user.getUserId()}})"

The aim is simple:

  • The user clicks on the link which updates the status via ajax (this works fine)
  • Reload the embedded controller only, not the entire page!

At the moment, I managed to do this, by reloading the entire page using document.location.reload(true); This has no point so far…

Here is the ajax part:

//...
function changeStatus(userId){
    $.ajax({
        type: "POST",
        url: ajaxControllerPath,
        data: "userId="+userId,
        success: function(){
            document.location.reload(true); 
        }
    });  
}

How would you reload the embedded controller only?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:26:47+00:00Added an answer on June 10, 2026 at 2:26 pm

    When you call the ajax controller, this controller could render the showUsersList template and return the generated html as a json object:

    $answer['html'] = $this->forward('AcmeUserBundle:User:showUsersList')->getContent(); 
    $response = new Response();                                                
    $response->headers->set('Content-type', 'application/json; charset=utf-8');
    $response->setContent(json_encode($answer));
    return $response
    

    Then in your javascript use this generated html to replace the content of the controller part of the page (use a div or similar to identify it)

    <div id="changethis">{% render "AcmeUserBundle:User:showUsersList"} %}</div>
    
    function changeStatus(userId){
        $.ajax({
            type: "POST",
            url: ajaxControllerPath,
            data: "userId="+userId,
            success: function(returnData){
                $('#changethis').html(returnData['html']);
            }
        });  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We can easily embed a controller within a template in twig: {% render AcmeGolferBundle:Golfer:showGolfersList
In symfony 2, one can embed a controller in a template. For example, I
I have a template that iterates over a controller array - and for some
I'm trying to embed data I have defined in my controller in my view.
I have a very simple MVC app at this point: Controller: public class HomeController
I have two TableViewControllers with a segue in-between. When a user clicks on a
Yes, I know you have to embed the google analytics javascript into your page.
Using C# for ASP.NET and MOSS development, we often have to embed JavaScript into
I have tried to embed a flash movie in a zend view using the
I have tried to embed the icalendar code in a email to be sent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.