Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How to use JQuery/Ajax in my case?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
heohni
Smarty Regular


Joined: 20 Sep 2006
Posts: 40

PostPosted: Wed Jun 30, 2010 1:47 pm    Post subject: How to use JQuery/Ajax in my case? Reply with quote

Hi,

I have this template:

Code:

<select name="loc" size="1">
                <option value="0">##NG_ALL_TOWNS##</option>
            {foreach from=$cities key="key" item="value"}
...
...


On Change of another select box, I would like to update this select above.
In better words, I would like to call a jquery ajax function wich gives me the content for $cities back.

My question now, how can I load the new content of the variable $cities into my template on runtime?

I do not want to replace the html, I would like to keep the smarty foreach, as later in the select I have to do other smarty related things, so I dont want to disturb my oriinal way of doing.

Thanks folks in advance!!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Jun 30, 2010 1:50 pm    Post subject: Reply with quote

You can't. Smarty variables are parsed on the server-side. You need to do your work client-side in javascript, no different than how you would handle it with just PHP.
Back to top
View user's profile Send private message Visit poster's website
heohni
Smarty Regular


Joined: 20 Sep 2006
Posts: 40

PostPosted: Wed Jun 30, 2010 3:12 pm    Post subject: Reply with quote

Pitty... but I understand what you are saying.

The only possible way would be to replace the html via jquery?
Because server-side means page refresh needed, right?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Jun 30, 2010 3:28 pm    Post subject: Reply with quote

Get it working with just PHP first, then use the same client-side code using Smarty. There are lots of scripts around the web that dynamically replace HTML elements with ajax/javascript. Any of them should work the same.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP