Diffence between usage of Ajax Update Panel and Jquery:ajax() method

穿精又带淫゛_ 提交于 2020-01-13 11:33:12

问题


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?

Please help me on this..


回答1:


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'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.

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.

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.



来源:https://stackoverflow.com/questions/17851179/diffence-between-usage-of-ajax-update-panel-and-jqueryajax-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!