简体   繁体   English

什么是处理ajax和生成超出原型的html的最佳方法

[英]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.

相关问题 进行原型制作时跟踪javascript对象引用的最佳方法是什么 - What the best way to keep track of a javascript object reference when prototyping 从 html 生成可保存图像的最佳方法是什么? - What is the best way for generating a saveable image from html? 处理浮点错误的最佳方法是什么? - What is the best way to deal with floating point errors? 处理此命名空间JavaScript结构的最佳方法是什么? - What is the best way to deal with this Namespace JavaScript Structure? 在Rails 4上处理AJAX的正确方法是什么? - What is the right way to deal with AJAX on Rails 4? 在Ajax中处理非常大的长数的最佳方法是什么? - Best way to deal with very large Long numbers in Ajax? 什么是处理react.js中未定义道具的最佳方法? - what's the best way to deal with undefined props in react.js? Javascript日期:处理夏令时的最佳方法是什么? - Javascript dates: what is the best way to deal with Daylight Savings Time? 处理侦听并触发事件的元素/对象的最佳方法是什么? - What is the best way to deal with elements/objects that listen AND trigger events? 处理来自交易结果的命令的最佳方法是什么? - What is the best way to deal with analyzing commands from transaction results?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM