内置页框VS阿贾克斯 [英] iframes vs ajax

查看:152
本文介绍了内置页框VS阿贾克斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一些标签(例如jQuery的选项卡),我想动态加载一些页面中的每个选项卡中,我能做到这一点有两种方式

Suppose i have some tabs (e.g. jquery tab) and I want to dynamically load some page in each tab, I can do that in two ways

  1. 使用jQuery的Ajax选项卡(基本填充DIV与阿贾克斯的数据) 或
  2. 在每个标签可以包含加载到一个iframe和页面。
  1. Use jquery ajax tabs (basically filling div with ajax data) or
  2. Each tab can contain an iframe and page loaded into that.

Q1 。我看到两种方法对用户没有什么区别,是不是?

Q1. I see no difference between two approaches to user, is there?

Q2 。我认为iframe的方式比较好,因为IFRAME可以加载任何页面,但有时加载ajax的数据转换成格可能无法按预期工作。

Q2. I think iframe way is better because iframe can load any page but sometimes loading ajax data into div may not work as expected.

推荐答案

首先,具有包含的网页(或AJAX调用)中的错误可能是更好的处理与Ajax方式。随着内置页框,你只会得到你的页面中间的一个丑陋的404或500错误。但随着AJAX可以检测到错误并显示对用户更加友好的错误消息。

For one, having an error in an included page (or ajax call) is probably better to handle with the ajax approach. With iframes you'll just get an ugly 404 or 500 error in the middle of your page. But with ajax you can detect the error and display a more user-friendly error message.

这也取决于您正在加载到您的网页什么样的数据。如果控件的HTML被加载,你可避免或解决任何可能出现的显示问题。如果你需要加载一个网页的控制之外,内置页框将是最好的(或需要)。

It also depends on what data you're loading into your page. If you control the html being loaded in, you can avoid or fix any display issues that may arise. If you need to load a page outside of your control, iframes would be best (or necessary).

也可能会涉及两种方法可访问性问题,但我不熟悉不够用,要确定哪种方法使用屏幕阅读器的效果最好,等等。

There may also be accessibility issues involved with either approach, but I'm not familiar enough with that to determine which approach works best with screen readers, etc.

这篇关于内置页框VS阿贾克斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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