开发者

what is the best way to deal with ajax and generating html that is beyond prototyping

开发者 https://www.devze.com 2023-03-14 04:47 出处:网络
For my project I am starting to get alot of embeded htm开发者_JAVA技巧l in my javascript as a result of ajax calls. I want to move them out of there. What is the best practice for this? I was thinking

For my project I am starting to get alot of embeded htm开发者_JAVA技巧l in my javascript as a result of ajax calls. I want to move them out of there. What is the best practice for this? I was thinking have the elements as a div in the page with display:none then deal with when the javascript needs it.

But If I use this method I need to replace certain string with the data return from my ajax call, any advise on that?

Thanks


You could use a templating framework such as jquery templates. Here's a blog post about it.

The are also other engines you might take a look at:

  • mustache
  • EJS
  • JavaScript Micro-Templating
0

精彩评论

暂无评论...
验证码 换一张
取 消