当不要在Web应用程序开发使用AJAX? [英] When NOT to use AJAX in web application development?

查看:133
本文介绍了当不要在Web应用程序开发使用AJAX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Web应用程序与Zend框架。我一直想加入一些AJAX类型的形式和模式的箱子,但我也希望我的应用程序,以尽可能接近。我想我的应用程序通过AJAX增强,而且功能齐全而不AJAX。

I'm building a web application with the Zend Framework. I have wanted to include some AJAX type forms and modal boxes, but I also want my application to be as accessible as possible. I want my application to be enhanced by AJAX, but also fully functional without AJAX.

因此​​,作为一个一般原则......当我不应该使用AJAX?我的意思是,我懒得做我的应用程序可以使用不带AJAX?或者每个人都具有AJAX功能的浏览器,这些天?

So as a general guideline...when should I not use AJAX? I mean, should I bother making my application usable without AJAX? Or does everyone have AJAX enabled browsers these days?

推荐答案

如果你指的是在ADA意义上的访问,AJAX通常是一个没有没有 - 你的网站应该只使用标准提供其所有的内容和核心功能( X)HTML和CSS。使用任何JavaScript应该仅仅是扩展了核心功能,并且您的站点应该是coded到在没有JavaScript的浏览器的优雅工作。

If you mean "accessible" in the ADA sense, AJAX is usually a no-no - your site should provide all its content and core functionality using only standard (X)HTML and CSS. Any javascript used should merely extend the core functionality, and your site should be coded to work elegantly in the absence of a javascript-enabled browser.

例如:如果你想要一个用户点击一个缩略图,并获得图像。其结果是一个全尺寸的版本,你可以让缩略图的链接。然后,onclick事件将触发一个jQuery方法取消链接的浏览行为,并弹出一个jQuery浮动div来显示当前页面上的图像。如果用户的浏览器不支持JavaScript,onclick事件将永远不会触发,并且用户将$ P $在新页面psented图像。核心功能是相同的有或无的脚本。

Examples: if you want a user to click on a thumbnail and get a full-size version of the image as a result, you can make the thumbnail a link. Then, the onclick event will fire a JQuery method that cancels the navigation behavior of the link and pops up a JQuery floating div to show the image on the current page. If the user's browser doesn't support JavaScript, the onclick event will never fire, and the user will be presented the image in a new page. The core functionality is the same with or without scripting.

编辑:骨架例如,SANS JQuery的专用code

Skeleton example, sans JQuery-specific code.

<html>
<body>
<a href="some.url" onclick="JQueryToOpenPopupImage(); return false;">Some URL</a>
</body>
</html>

要取消导航操作,只需确保通过调用该方法的的onclick 在结束活动返回false。

To cancel the navigation operation, simply make sure that the method invoked by the onclick event returns false at the end.

一个精巧的例子,JQuery的图像弹出我的描述,可以发现<一href="http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/">here.

A neat example of the JQuery image popup I described can be found here.

这篇关于当不要在Web应用程序开发使用AJAX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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