使用Ajax Update Panel和Jquery:ajax()方法之间的差异 [英] Diffence between usage of Ajax Update Panel and Jquery:ajax() method

查看:95
本文介绍了使用Ajax Update Panel和Jquery:ajax()方法之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Update Panel的用法和Jquery:Ajax()方法的用法感到困惑.

I am little confused about Update Panel usage and usage of Jquery:Ajax() method.

这两个都用于部分发回邮件吗.

Do both of them are used for Partial Post backs..

哪种是最好的休闲方式?

Which is the best approach to fallow?

请帮助我.

推荐答案

更新面板对页面进行完整的重新渲染,获取与面板匹配的部分并将其发送回客户端.然后,浏览器将更新面板的内容替换为新的html.

An update panel performs a full re-render of the page, takes the section matching the panel and sends it back to the client. The browser then replaces the contents of the update panel with the new html.

jQuery的AJAX方法允许您对任何页面进行任何请求,并以您选择的任何方式处理响应数据.这可能包括从Web服务读取JSON响应,获取html或您希望的其他任何内容.有效地,AJAX为您提供了一种机制,可以模拟用户浏览具有GET或POST数据的给定URL并以您希望的任何方式操纵结果.

jQuery's AJAX method allows you to make any request to any page and handle the response data any way you choose. This might include reading a JSON response from a web service, getting html or anything else you wish. Effectively AJAX gives you a mechanism to emulate the user browsing to a given url with GET or POST data and manipulate the results in any way you desire.

值得注意的是,更新面板是基于AJAX构建的(技术上是Javascript的 XMLHttpRequest )对象.

It's worth noting that the update panel is built on top of AJAX (technically Javascript's XMLHttpRequest) object.

还有一些更新面板的陷阱,例如,如果验证码在面板外部;面板更新后,用户可见的验证码不会更改.服务器会生成一个新页面,其中包括一个新的验证码.当用户提交表单时,其验证码用于旧的验证码.

There are also some gotchas with update panel, eg if you have a Captcha that is outside the panel; When the panel is updated, the captcha visible to the user doesn't change. The server generates a new page, including a new captcha. When the user submits the form, their verification code is for an old captcha.

简而言之,您可以使用AJAX进行更多控制,并且学习如何使用它会有所帮助,但是根据您的用例,更新面板可能会做些您需要的事而省去的精力.

In short, you have more control with AJAX and learning how to use it will be beneficial but depending on your use case, an update panel may do what you need for less effort.

这篇关于使用Ajax Update Panel和Jquery:ajax()方法之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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