0

I'm messing with using AJAX to fetch "partial templates" from the server and echoing them back to the browser. This will cause all this HTML to have to be sent back to the browser. I was wondering if there is a way to simply change the variables but leave all the html there. Something like this:

$smarty->assign("fruit", "apple"); // At Load

$smarty->assign("fruit", "pear"); // Changed through an AJAX call..

Then something like..

$smarty->reload('FruitTemplate'); // Reloads all the variables

Any ideas?

Thanks! Matt Mueller

2
  • 2
    Smarty is a server side technology. Once the page is loaded you can't change the page using Smarty unless you reload the page. You can certainly use Smarty in an AJAX call but that's only going to return some new HTML to your page. Once it's loaded Smarty can't see the rest of the page that your client already has loaded. Maybe I don't understand your question.
    – Cfreak
    Aug 8, 2009 at 5:33
  • Maybe you should post your answer as an answer Cfreak?
    – Toby Allen
    Oct 11, 2009 at 20:56

1 Answer 1

0

I'm afraid Cfreak is right smarty works on the server, essentially you are doing exactly what you say you want to do on the client on the server. The only way to do what you want would be through javascript.

However is it really a problem. unless you html files are huge it shouldnt cause any problems for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.