开发者

When Ajax should be used and when it should not? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 开发者_如何学Python13 years ago.

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 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 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.


That is not an easy question to answer without more information about your application. I find myself using Ajax to save very complicated pages. For instance I might have a page with a datagrid on it where people can enter multiple records at a time. It is also nice when you want to do partial updates of pages maybe when filtering a list or doing paging. Using ajax usually a lot more work than just posting back to the server so don't go too overboard.


For me, Ajax is useful in interacting with the DB, and for JQuery is for trapping entries of the user without bothering the whole page. So AJAX and JQuery, if mastered, will create a one hell of a website.


For when not to use it see When NOT to use AJAX in web application development?

In terms of when to use it my thoughts are:

  • When you don't want the user to endure a full refresh of the page when they trigger an action
  • When a rich UI is important to you.
  • When you can achieve the same effect without using AJAX using Jquery/JavaScript
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜