[英]what is the best way to deal with ajax and generating html that is beyond prototyping
For my project I am starting to get alot of embeded html in my javascript as a result of ajax calls. 对于我的项目,由于ajax调用,我开始在我的javascript中获得大量嵌入的html。 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. 我当时在想在display的页面中将元素作为div:然后在javascript需要时再进行处理。
But If I use this method I need to replace certain string with the data return from my ajax call, any advise on that? 但是,如果我使用此方法,则需要用ajax调用返回的数据替换某些字符串,对此有何建议?
Thanks 谢谢
You could use a templating framework such as jquery templates . 您可以使用模板框架,例如jquery模板 。 Here's a blog post about it. 这是关于它的博客文章 。
The are also other engines you might take a look at: 您还可以看看其他引擎:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.