Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

How to reload a separate template via Ajax?


Reply


4 Posts   843 Views

Avatar
Romano

Community Member, 13 Posts

12 April 2011 at 1:18am

Hello! I have a template in Include folder, like this:

<div id="mytemplate">
   <% control MyControl(5) %>   
      $Content
   <% end_control %>
</div>

How I can change dynamically the value of a parameter for MyControl (e.g. 5 to 10) and reload only this template without reload the site?

Such as: onClick="javascript:function(paramvalue);"

Thanks.

Avatar
swaiba

Forum Moderator, 1805 Posts

12 April 2011 at 1:59am

Edited: 12/04/2011 2:00am

well you could render your template independently with...
Controller...

function MyAJAX() {
Session::set('MyControlcount',Convert::raw2xml($_POST['PostedValue]));
return $this->renderWith('IncludeTemplate');
}

...

function MyControl() {
$iCount = Session::get('MyControlcount');
if (empty($iCount)) $iCount=5;//defualt
//do and return stuff
}

template...

<div id="mytemplate">
<% control MyControl() %>
$Content
<% end_control %>
</div>

Avatar
Romano

Community Member, 13 Posts

12 April 2011 at 10:33pm

Edited: 12/04/2011 11:25pm

Thank you! Last question. How I can set $_POST['PostedValue'] via Ajax without receiving page?

Avatar
Romano

Community Member, 13 Posts

12 April 2011 at 11:18pm

Edited: 12/04/2011 11:25pm

Solved! I Must have been use method GET ($_GET['PostedValue']).