网站严格使用静态 html 文件、jquery、ajax 和 json Web 服务?
我使用 ASP.Net MVC 一段时间了,我一直在想:
<% foreach(ItemRow in Items) { %> <div><%=ItemRow.Description%></div> <% } %>
让我想起了 ASP Classic 和 PHP。是的,确实有一些改进,但它仍然让我有点畏缩。
我一直在考虑,不要只编写静态 html,而是严格使用 jQuery 从 Web 服务收集 JSON 结果并适当地填充页面。有人尝试过这种方法吗?你的经历是什么?
I've been using ASP.Net MVC for a while now and I've been thinking that this:
<% foreach(ItemRow in Items) { %> <div><%=ItemRow.Description%></div> <% } %>
Reminds me a little too much of ASP Classic and PHP. Yeah there are definite improvements but it still makes me cringe a little.
I've been thinking instead of writing nothing but static html and strictly using jQuery to gather JSON results from webservices and populate the page appropriately. Has anyone tried this approach? What was your experience?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现自己越来越多地这样做。我发现制作简单的以客户为中心的应用程序会更快。唯一的“问题”是安全性和会话状态管理。但这并不是交易杀手。
取决于您的看法,但我们发现的积极因素之一是我们可以构建业务层和数据层,允许我们的前端开发人员在没有太多限制的情况下构建他们的界面愿景,最后我们可以让经验不足的开发人员做很多事情更多连接 jquery 的东西。从业务角度来看,这具有更高的投资回报率,因为我可以让高端工程师和开发人员更好地利用他们的时间。
I have been finding myself doing this more and more. I find it quicker to do simple customer-centric apps. The only "issues" are security and session state management. But it is not a deal killer.
Depends on your view, but one of the positives we have found is that we can build the business and data layers, allow our front end developers to build their interface vision without many restrictions, and finally we can allow a less experienced developer do a lot more of wiring the jquery stuff. Which from a business perspective has a higher ROI as i can dedicate the higher end engineers and developers to do better use of their time.
我同意,在您看来,具有以下内容
可能很丑陋。这就是我编辑/显示模板的原因。所以代码看起来像这样:
在相应的显示模板中:
至于你的第二个问题是关于使用 jQuery 从各种 Web 服务收集 JSON 数据并构建 UI,这是一种可能适用于更简单场景的方法,但恕我直言复杂的业务应用程序您可能需要考虑 ASP.NET MVC 甚至 Silverlight。
I agree that having the following:
in your view might be ugly. That's why I editor/display templates. So the code looks like this:
and in the corresponding display template:
As far as your second question is concerned about using jQuery to gather JSON data from various webservices and build the UI, it is an approach that might work for simpler scenarios but IMHO for complex business applications you might want to consider ASP.NET MVC or even Silverlight.