什么时候应该使用Ajax,什么时候不应该使用? [英] When Ajax should be used and when it should not?

查看:98
本文介绍了什么时候应该使用Ajax,什么时候不应该使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正计划在Web应用程序中使用Ajax,但是由于我是新手并且没有太多经验,所以我想知道何时应该使用Ajax,何时不应该使用Ajax?我打算用jQuery/php进行编码,如果有什么不同的话.

I’m planning on using Ajax with my web application, but as I’m novice and don’t have much experience I wonder when ajax should and when should not be used? I plan to code with jQuery/php if it makes any difference.

推荐答案

当您的应用程序希望以多种不同的方式向用户展示数据集时,AJAX最为有用.当没有延迟等待服务器重新绘制页面并通过网络发送页面时,排序和过滤以及通常与数据集进行交互的感觉最佳.这对于处理到达服务器的新数据的显示也很不错-客户端只需拉出新数据并将其合并到客户端上的数据集中即可,而无需整个页面绘制,包括您已拥有的所有数据见过.这样可以节省大量带宽.

AJAX is most useful when your application wants to present a data set to its user in many different ways. Sorting and filtering and in general interacting with a data set feels best when there are no delays waiting for a server to redraw the pages and send them over the network. It's also nice for handling display of new data arriving on the server -- the client can just pull the data that is new and merge it into the data set on the client rather than requiring a whole new page draw including all the data you've seen before. This can save quite a bit of bandwidth.

当您需要使应用程序保持简单时,不应使用AJAX,尽管诸如jquery之类的技术使客户端变得越来越容易正确.但总的来说,我想说的是,如果您要传递的信息是静态的-仅需要以一种或两种方式查看,那么AJAX方法可能只是工程过度.

AJAX should not be used when you need to keep your application simple, though technologies like jquery are making the client side easier and easier to get right. But in general I would say that if the information you're delivering is pretty static -- it only needs to be viewed in one or two ways, then an AJAX approach may just be overengineering.

这篇关于什么时候应该使用Ajax,什么时候不应该使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆