|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
n2fole00 Smarty Rookie
Joined: 09 Jun 2020 Posts: 7
|
Posted: Mon Jul 06, 2020 12:26 pm Post subject: Passing variables to child loaded with ajax content |
|
|
Hi, If I have a template and inside that template I have a child template whose content is called via an ajax request, is it possible to pass down (or make available) variables from the parent template to the child template, taking into consideration this is dynamically loaded?
Thanks. |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Tue Jul 07, 2020 1:48 am Post subject: |
|
|
I would think this "inheritance" or "passing along" data that populated one template - Smarty performs this population of the template on the server - to be available on a child template, can happen, as long as the child template is also having that data populate that child template at the same time on the server.
Knowing that AJAX calls are performed by the web browser, and this fetching is at a separate point in time, it then leads me to conclude that processing the AJAX request will need to have some code on the server perform the necessary data gathering and processing for that response.
That code could be gathering and processing the same data to populate a 'child/dynamic' area of the page (including having Smarty create an HTML snippet using a template) as was done to populate the 'parent' area of the page. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Jul 16, 2020 12:50 am Post subject: |
|
|
Correct. AJAX request happens when Smarty is long since dead, not to mention - it happens outside the server to begin with. Use client scripting to deal with data received from AJAX request. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|