AJAX基本问题 [英] AJAX basic question

查看:126
本文介绍了AJAX基本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



谁能解释一下ajax更新面板的工作原理,我也想知道为什么javascript无法在内部工作

更新面板

如有疑问,请帮助我

感谢

Hi ,

Can anyone explain me how ajax update panel works and also i would like to know why javascript is not working inside

update panel

please help me for my doubt

Thanks

推荐答案

在此处阅读有关AJAX更新面板如何工作的信息:
UpdatePanel控件概述 [ UpdatePanel控件 [ UpdatePanel类 [
Read here on how AJAX Update Panel works:
UpdatePanel Control Overview[^]
UpdatePanel control[^]
UpdatePanel Class[^]

All you need to know with sample code is present and explained.


UpdatePanel 被设计为最简单的方式来启用AJAX网站,重点是AJAX的最重要功能:将更新限制在页面内的某个区域,而不需要完全刷新.尽管它完全改变了浏览器发出请求的方式,但UpdatePanel的编写方式使您的页面可以正常执行,这意味着您不必重写任何控件或服务器端逻辑.

当浏览器加载AJAX框架时,JavaScript onsubmit处理程序将添加到页面上的每个表单元素.提交表单后,处理程序将检查这是否应为部分更新"-由更新面板处理.如果是这样,它将收集所有发送到服务器的数据,对其进行重新打包,然后使用XmlHttpRequest对象将其发送,而不是作为常规浏览器请求发送.在浏览器中,onsubmit处理程序现在返回false,有效地告诉浏览器取消整个页面刷新.同时,该请求已发送到您的Web服务器,就像普通请求一样,只是有所不同:额外的HTTP标头使AJAX基础结构知道这是部分更新.

该页面正常执行,并且已收集输出以准备发送到浏览器.但是,在发送之前,还有一点AJAX魔术开始.UpdatePanel不需要的所有内容都被剥离,并且发送了一些额外的数据(包括UpdatePanel中未包含的控件的更新的隐藏字段和ViewState).

当它返回浏览器时,JavaScript库将更新所有内容,包括UpdatePanel的内容,以及所有其他数据.如果您的ASP.NET页面更新了页面标题甚至页面的CSS样式,所有这些都会自动更新.

如何使javascript与Ajax UpdatePanel一起使用 [ ^ ]
The UpdatePanel is designed to be the easiest possible way to AJAX-enable your site, focusing on the most important feature of AJAX: restricting updates to an area within a page instead of requiring a full refresh. Although it completely changes how requests are made by the browser, the UpdatePanel is written in such a way that your pages execute normally, which means you don not have to rewrite any controls or server-side logic.

As the browser loads the AJAX framework, a JavaScript onsubmit handler is added to every form element on the page. When the form submits, the handler checks whether this should be a "partial update" – one handled by an update panel. If so, it collects all the data being sent to the server, repackages it, and sends it, not as a regular browser request, but using the XmlHttpRequest object. In the browser, the onsubmit handler now returns false, effectively telling the browser to cancel the full page refresh. Meanwhile, the request has made its way to your web server looking just like a normal request with one difference: an extra HTTP header lets the AJAX infrastructure know that this is a partial update.

The page executes as normal and the output is collected ready to be sent to the browser. Just before it is sent however, another bit of AJAX magic kicks in. Everything that is not needed for the UpdatePanel is stripped out and some extra data is sent (including updated hidden fields and ViewState for controls not included in the UpdatePanel).

When this arrives back at the browser, the JavaScript library updates everything, including the contents of the UpdatePanel, but also all the extra data. If your ASP.NET page updates the page title or even the page’s CSS styles, all of these are updated automatically.

How to make javascript work along with Ajax UpdatePanel[^]


这篇关于AJAX基本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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