如何构建一个ajax Web应用程序,如果浏览器不支持javascript,它可以优雅地回退?
抱歉标题很长,但我关心的是构建一个基于 ajax 的应用程序。
我有这个应用程序的第一个版本,它不需要 javascript 即可运行,我想将其迁移为使用 ajax 来获取来自第 3 方肥皂网络服务的各种资源。
如何构建一个 ajax 应用程序,当浏览器没有 javascript 或禁用它时,该应用程序仍能正常运行? (服务器端代码已经过测试并已投入生产,因此我确实有坚实的基础可以依靠,只是不确定如何以优雅的方式做到这一点。)
我熟悉所有工具(客户端和服务器端)并计划使用 jquery 框架,但不确定 javascript 未在浏览器上运行的部分以及我的应用程序如何仍然运行。
Sorry for long title but my concern is with constructing an ajax based application.
I have a version one of this application which does not require javascript to function, I want to migrate this to use ajax for various resources that come from a 3rd party soap web service.
How can I build an ajax application which when the browser does not have javascript or has it disabled will still function properly? (The server side code is tested and in production so I do have a solid foundation to fall back on just not sure how to do this in a graceful maner.)
I am familiar with all the tools (client and server side) and plan on using jquery framework but not sure about the part where javascript isn't running on the browser and how my application can still function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JQuery 非常擅长支持 Web 应用程序的“优雅降级”。您可以通过在页面加载后添加功能(通过使用 $(document.ready() 方法))将 AJAX 功能应用到非 javascript 页面。您需要捕获页面上会导致页面重新加载(“click()”、“submit()”等)、停止触发传统浏览器事件(“preventDefault()”)以及调用 AJAX 函数,您可能需要更新和/或。构建一些 API 包装器或 Web 服务函数(取决于您的环境)来生成 AJAX 函数可以吸收的响应,然后将其呈现给浏览器,
我建议开始这种形式的 Web 应用程序开发。关闭 jQuery 文档,如果您遇到问题,请在此处发布具体问题(带有代码片段)并我相信您会得到很多答案和反馈,祝您好运!
JQuery is very good at supporting "graceful degredation" for web apps. You can apply the AJAX functionality to your non-javascript page by adding functionality after the page has loaded (through use of the $(document.ready() method). You'll need to catch the triggers on your page that would cause a page to reload ('click()', 'submit()', etc), stop the traditional browser event from firing ('preventDefault()'), and make calls to you AJAX functions. You may need to update and/or construct a few API wrappers or web service functions (depending on your environment) to generate responses that the AJAX functions can absorb and then render out to the browser.
This is a very common and well-practiced form of web app development. I suggest starting off with the jQuery documentation and if you run into issues, post specific questions (with code snippets) back here and I'm sure you'll get lots of answers and feedback. Good luck!