我确信他们都有自己的特定功能,所以我不想知道哪一个更快等等,我更想知道何时使用哪个从另一个页面检索数据?
<iframe> load(); ajax();
解决方法
Given that framing is deprecated,and
AJAX
has origin control,iframes
is pretty much the only way to embed another page into yours.GMail is made from
iframes
. The smooth UX of GMail (you can still use
it when your internet connection breaks,smooth navigation without
having to reload every time) comes from iframes. Again,this Could be
implemented in AJAX,but it’s harder.On the other hand,issues with iframes (CSRF,clickjacking,etc) are
well kNown to modern developers and they can take measures to avoid
that.
– 何时使用Ajax?
表格验证
This is almost a no-brainer. It’s so much nicer when the form tells
you as you are typing if you’ve filled it out wrong or not. Having to
go to the server and then return an error message is not only old,
it’s slow. Leave the server validation in the form,that’s important
for accessibility. But for those who can support Ajax,tell them right
away.
Comments on blogs or even just articles are a great use of Ajax.
Comments can change all the time,and especially when a commenter hits
the comment button,it’s nice to see the comment appear immediately on
the page.
过滤数据
If you’ve got a large table with a lot of data in it,a nice
application for Ajax is to add filters and sorters to the table.
Getting your Web table to act more like Excel is really useful to
people.
调查和民意调查
When you click on your Vote,the poll would just switch to show you
the results. And before you comment,About doesn’t yet support Ajax on
our polls – but it sure would be nice. Maybe we can give the About.com
developers an “Ajax call” of our own.
>何时使用负载?
As far as
load
is concerned,in my personal opinion,it is used to
load documents into any element in DOM,but will have same
disadvantages asajax
overiframe
with regard to cross domain
data. You can use load when the result you are returning ishtml
and this provides option to render the result directly to theDOM
element
更新:
>何时使用AJAX
Basically,the main difference between
ajax
andload
is thatajax
has moreoptions
that can be set before posting data toserver
plusajax
can be used to storedata
in the server usingtype="POST"
and data returned from the server may be manipulated the
way we want unlike load which can be used only to render data.
总结一下 – 安全明智的ajax / load是好的,但如前所述,如果你知道使用iframe的安全漏洞,你可以采取必要的预防措施来防止它们.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。