对于我们的下一个项目,我想进入一些AJAX来改进用户界面。指南和建议?

时间:2022-06-18 11:21:44

Our team is experienced in web development (tomcat/Oracle) but not with AJAX on our existing projects. This is new technology for us, so I want to introduce this carefully and correctly.

我们的团队在Web开发(tomcat / Oracle)方面经验丰富,但在现有项目中没有使用AJAX。这对我们来说是新技术,所以我想仔细而正确地介绍这一点。

What should I look at in terms of frameworks or best practice or common pitfalls?

在框架或最佳实践或常见陷阱方面,我应该注意什么?

6 个解决方案

#1


3  

My first recommendation would be to explore the different frameworks available and see what your team prefers in terms of coding style. Most of the frameworks have the same basic features so a lot of it comes down to preference. I prefer jQuery, so that is my first recommendation, but I worked with YUI, MooTools, Prototype and EXT JS before making my decision.

我的第一个建议是探索可用的不同框架,并了解您的团队在编码风格方面的偏好。大多数框架具有相同的基本功能,因此很多框架都归结为偏好。我更喜欢jQuery,所以这是我的第一个建议,但在做出决定之前我曾与YUI,MooTools,Prototype和EXT JS合作过。

Secondly, I would recommend working AJAX functionality as a progressive enhancement, allowing your apps to work with and without JavaScript. I find that this approach also ensures a solid, working application before worrying about adding the bells and whistles.

其次,我建议将AJAX功能作为渐进增强功能,允许您的应用程序使用和不使用JavaScript。我发现这种方法在确保添加铃声和口哨之前也确保了可靠的工作应用。

Head First Ajax is a good book IMO for getting started with the basic concepts behind working with Ajax. It would probably be a good place to start for your team to gain some knowledge of what is happening behind the scenes in whatever framework you choose.

Head First Ajax是一本很好的书IMO,用于开始使用Ajax的基本概念。这可能是一个很好的起点,让您的团队在您选择的任何框架中了解幕后发生的事情。

#2


4  

read this:

and use a library such as jQuery, mootools, or YUI it'll save you many headaches with cross-browser implementation. this will show you why you want to use a library.

并使用诸如jQuery,mootools或YUI之类的库,它将通过跨浏览器实现为您节省许多麻烦。这将告诉您为什么要使用库。

#3


1  

One thing we struggled with when starting to use ajax was how often to use it.

我们在开始使用ajax时遇到的一件事就是经常使用它。

We had no exact requirement as to where we were supposed to use ajax and not, and initially we erred to the side of using it too much. This affected application complexity quite a lot.

我们没有确切要求我们应该在哪里使用ajax而不是,并且最初我们错误地使用它太多了。这极大地影响了应用程序的复杂性。

If you think of your inter-page-structure as a state-machine, ajax introduces nested state-machines within each page-state. The moment your sub-state machine ends up with a number of distinct states (I'd say anything over 2), you should think really hard about using a traditional approach.

如果您将页面间结构视为状态机,则ajax会在每个页面状态中引入嵌套状态机。当你的子状态机结束时有许多不同的状态(我会说任何超过2的状态),你应该认真考虑使用传统的方法。

The best starting point is to try to get a mix og full page reloads and ajax, and be conservative until you're sure you're getting really good at it.

最好的起点是尝试混合og整页重新加载和ajax,并保守,直到你确定你真的很擅长它。

#4


1  

Don't use it where you don't need it.

不要在不需要的地方使用它。

Long running operations that need to send the client some status updates? Use AJAX.

需要向客户端发送一些状态更新的长时间运行操作?使用AJAX。

Markup for major UI elements (menus, ect)? Use plain old HTML.

主要UI元素(菜单等)的标记?使用普通的旧HTML。

Basically, use AJAX for transmitting data only. If you try do fancy things like dynamically pulling in UI elements on the client side with AJAX, you are in for a world of hurt when you get a client who wants to use ie5 (they exist), or a non-pc based browser.

基本上,使用AJAX仅传输数据。如果您尝试使用AJAX在客户端动态提取UI元素等花哨的东西,当您获得想要使用ie5(它们存在)或非基于PC的浏览器的客户端时,您将面临一个受伤的世界。

#5


0  

first, look at the user interface you already have, and consider where it might make sense for its elements to be able to change/react independently. This is where your ajax enhancements might make sense

首先,查看您已有的用户界面,并考虑其元素能够独立更改/反应的位置。这是您的ajax增强功能可能有意义的地方

second, look at libraries as noted in the other answers (I like AJAXPRO for its simplicity, but it has been discontinued)

第二,看看其他答案中提到的库(我喜欢AJAXPRO的简单性,但它已经停产)

if you find that all of your page elements tie together and cannot change independently, then there is really no need for ajax

如果您发现所有页面元素都绑定在一起并且无法独立更改,那么实际上不需要ajax

otherwise, consider how you will access the page state from your ajax enhancement points - depending on which ajax framework you use, you may or may not have access to the entire page object, session state, original request parms, etc. Consider these issues up front to avoid coding yourself into a hole and/or having to make messy workarounds.

否则,请考虑如何从ajax增强点访问页面状态 - 根据您使用的ajax框架,您可能有也可能无法访问整个页面对象,会话状态,原始请求参数等。请考虑这些问题避免将自己编入一个洞和/或不得不制作凌乱的解决方法。

#6


0  

If you were on .Net or Mono I would encourage you to use Ra-Ajax which abstracts away JavaScript completely. Though I work for Ra-Ajax (inventor) so I am biased...

如果您使用.Net或Mono,我会鼓励您使用完全抽象JavaScript的Ra-Ajax。虽然我为Ra-Ajax(发明家)工作,所以我有偏见......

#1


3  

My first recommendation would be to explore the different frameworks available and see what your team prefers in terms of coding style. Most of the frameworks have the same basic features so a lot of it comes down to preference. I prefer jQuery, so that is my first recommendation, but I worked with YUI, MooTools, Prototype and EXT JS before making my decision.

我的第一个建议是探索可用的不同框架,并了解您的团队在编码风格方面的偏好。大多数框架具有相同的基本功能,因此很多框架都归结为偏好。我更喜欢jQuery,所以这是我的第一个建议,但在做出决定之前我曾与YUI,MooTools,Prototype和EXT JS合作过。

Secondly, I would recommend working AJAX functionality as a progressive enhancement, allowing your apps to work with and without JavaScript. I find that this approach also ensures a solid, working application before worrying about adding the bells and whistles.

其次,我建议将AJAX功能作为渐进增强功能,允许您的应用程序使用和不使用JavaScript。我发现这种方法在确保添加铃声和口哨之前也确保了可靠的工作应用。

Head First Ajax is a good book IMO for getting started with the basic concepts behind working with Ajax. It would probably be a good place to start for your team to gain some knowledge of what is happening behind the scenes in whatever framework you choose.

Head First Ajax是一本很好的书IMO,用于开始使用Ajax的基本概念。这可能是一个很好的起点,让您的团队在您选择的任何框架中了解幕后发生的事情。

#2


4  

read this:

and use a library such as jQuery, mootools, or YUI it'll save you many headaches with cross-browser implementation. this will show you why you want to use a library.

并使用诸如jQuery,mootools或YUI之类的库,它将通过跨浏览器实现为您节省许多麻烦。这将告诉您为什么要使用库。

#3


1  

One thing we struggled with when starting to use ajax was how often to use it.

我们在开始使用ajax时遇到的一件事就是经常使用它。

We had no exact requirement as to where we were supposed to use ajax and not, and initially we erred to the side of using it too much. This affected application complexity quite a lot.

我们没有确切要求我们应该在哪里使用ajax而不是,并且最初我们错误地使用它太多了。这极大地影响了应用程序的复杂性。

If you think of your inter-page-structure as a state-machine, ajax introduces nested state-machines within each page-state. The moment your sub-state machine ends up with a number of distinct states (I'd say anything over 2), you should think really hard about using a traditional approach.

如果您将页面间结构视为状态机,则ajax会在每个页面状态中引入嵌套状态机。当你的子状态机结束时有许多不同的状态(我会说任何超过2的状态),你应该认真考虑使用传统的方法。

The best starting point is to try to get a mix og full page reloads and ajax, and be conservative until you're sure you're getting really good at it.

最好的起点是尝试混合og整页重新加载和ajax,并保守,直到你确定你真的很擅长它。

#4


1  

Don't use it where you don't need it.

不要在不需要的地方使用它。

Long running operations that need to send the client some status updates? Use AJAX.

需要向客户端发送一些状态更新的长时间运行操作?使用AJAX。

Markup for major UI elements (menus, ect)? Use plain old HTML.

主要UI元素(菜单等)的标记?使用普通的旧HTML。

Basically, use AJAX for transmitting data only. If you try do fancy things like dynamically pulling in UI elements on the client side with AJAX, you are in for a world of hurt when you get a client who wants to use ie5 (they exist), or a non-pc based browser.

基本上,使用AJAX仅传输数据。如果您尝试使用AJAX在客户端动态提取UI元素等花哨的东西,当您获得想要使用ie5(它们存在)或非基于PC的浏览器的客户端时,您将面临一个受伤的世界。

#5


0  

first, look at the user interface you already have, and consider where it might make sense for its elements to be able to change/react independently. This is where your ajax enhancements might make sense

首先,查看您已有的用户界面,并考虑其元素能够独立更改/反应的位置。这是您的ajax增强功能可能有意义的地方

second, look at libraries as noted in the other answers (I like AJAXPRO for its simplicity, but it has been discontinued)

第二,看看其他答案中提到的库(我喜欢AJAXPRO的简单性,但它已经停产)

if you find that all of your page elements tie together and cannot change independently, then there is really no need for ajax

如果您发现所有页面元素都绑定在一起并且无法独立更改,那么实际上不需要ajax

otherwise, consider how you will access the page state from your ajax enhancement points - depending on which ajax framework you use, you may or may not have access to the entire page object, session state, original request parms, etc. Consider these issues up front to avoid coding yourself into a hole and/or having to make messy workarounds.

否则,请考虑如何从ajax增强点访问页面状态 - 根据您使用的ajax框架,您可能有也可能无法访问整个页面对象,会话状态,原始请求参数等。请考虑这些问题避免将自己编入一个洞和/或不得不制作凌乱的解决方法。

#6


0  

If you were on .Net or Mono I would encourage you to use Ra-Ajax which abstracts away JavaScript completely. Though I work for Ra-Ajax (inventor) so I am biased...

如果您使用.Net或Mono,我会鼓励您使用完全抽象JavaScript的Ra-Ajax。虽然我为Ra-Ajax(发明家)工作,所以我有偏见......