I'm using Symfony2 and I have some code to execute. It performs some database backup type work. That is not important for this question.
What I want is when I press a button it'll perform the code and get back to the main view. Don't load / reload any page. But controller is always expecting a response.
The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller?
So I tried to fake it with null
Button code like
<li id="menu"><a href="{{ path('backup_label') }}"><span class="icon-align-justify"></span> Backup</a></li>
And response codes that I tried
return $this->render(
null,
array('status' => 'ok')
);
OR
return $this->render(
'',
array('status' => 'ok')
);
OR
return new Response('<html><body></body></html>')
OR
return new Response()
These are either returning error or blank page.
What's the way to execute some php code without getting a new response? Call a function,execute and keep the same view without any loading, Simple.
I can do it using ajax. But I'm hoping that if it's possible without ajax.