当Javascript被禁用时,AJAX应用程序应该如何表现 - 通常的做法? [英] how AJAX application should behave when Javascript is disabled - common practice?

查看:57
本文介绍了当Javascript被禁用时,AJAX应用程序应该如何表现 - 通常的做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发非常基本的Web应用程序,这主要是因为我可以在途中学习jQuery / ajax / php(并且有一些乐趣)。我希望尽可能让用户可以访问它,因此它应该禁用Javascript,验证AAA以及所有这些。随着JS被禁用,当然没有所有的花里胡哨,但仍然应该做的工作。

I’m in the process of developing pretty basic web application, that is mostly so I could learn jQuery/ajax/php on the way (and have some fun). I want to make it as accessible to users as possible so it should work with Javascript disabled, validate to AAA and all that. With JS disabled would be of course without all the bells and whistles, but nevertheless should do the job.

我想充分利用Ajax,但我不完全明白当JS关闭时我应该如何应对。

I would like to make good use of Ajax, but I don’t fully understand how should I cope when JS is off.

因此,假设JS已启用,用户提交表单,单击提交按钮并通过ajax,数据将提交到register.php(register.php在表单操作中指定)属性)。 register.php返回数据,jQuery显示相应的消息。全部没有重新加载页面。

So let’s say JS is on, user submits the form, clicks submit button and thru ajax, data is submitted to register.php (register.php is specified in forms action attribute). register.php returns data and jQuery displays appropriate message. All without reloading the page.

现在,如果JS被禁用,向register.php提交表单将无济于事。

Now, if JS is disabled, submitting form to register.php won’t do much good.

我理解它的方法,解决方案是为JS启用一个php脚本,其他用于JS禁用。因此,默认情况下,form将具有 nonjs_register.php 的action属性,如果启用了JS,则会强制将表单提交给 js_register。 php 而不是默认 nonjs_register.php
我可以想象,为每个用户与应用程序的交互创建两个脚本页面会非常繁琐,但这是我现在能想到的唯一方法。

The way I understand it, solution would be to create one php script for JS enabled, other for JS disabled. So by default form would have action attribute with nonjs_register.php, and if JS would be enabled, it would force the form to be submitted to js_register.php rather than default nonjs_register.php. I can imagine that would be quite tedious to create two scripts pages for each user interaction with the application but that’s the only way I can think of at the moment.

我希望所有这些都有意义,但如果我的解释不太清楚,请告诉我。
现在,如果有人能够向我解释处理那种可能很好的问题的常见做法。

I hope all that makes sense but please let me know if my explanation is not quite clear. Now if anyone could explain to me what is the common practice to deal with that kind of problem that would be great.

推荐答案

查看 Hijax技术 ,这是一种使用AJAX作为渐进增强的方式。

Take a look at the Hijax technique, it's a way of using AJAX as a progressive enhancement.

这篇关于当Javascript被禁用时,AJAX应用程序应该如何表现 - 通常的做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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