---
title: "在ASP.NET中使用Callback实现AJAX"
author: "cetusz"
date: "2009-07-12T06:52:00Z"
tags: []
slug: "asp-net-callback-ajax"
draft: false
lastmod: "2009-07-12T06:52:00Z"
id: 787148
url: "https://cetus.iteye.com/blog/787148"
---

在许多时候，我们需要从客户端运行服务器代码而不执行回发，要实现这样的效果有非常多的方法，可以使用ASP.NET 中的 AJAX 功能，也可以使用象AjaxPro这样的第三方控件。这里我们要讨论的是使用Callback来实现AJAX。

    要实现客户端回调的ASP.NET页的CS代码与创建ASP.NET页的过程类似，但也存在一些区别。该页的服务器代码必须：1、实现ICallbackEventHandler接口；2、提供RaiseCallbackEvent方法的实现；3、提供GetCallbackResult方法的实现。同时在客户端必须三个脚本函数：1、一个函数调用帮助器方法，该方法执行对服务器的实际请求；2、客户端回调函数，处理回调事件的服务器代码的结果调用并接收该结果；3、第三个函数是执行实际服务器请求的 Helper 函数。当在服务器代码中使用 GetCallbackEventReference方法生成对此函数的引用时，ASP.NET 将自动生成此函数。

    现在，我们从实例来分析Callback的实现方法。

.aspx页源代码：

&lt;!-- &lt;br /&gt; &lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware) &lt;br /&gt;http://www.CodeHighlighter.com/ &lt;br /&gt; &lt;br /&gt;--&gt;![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="CallbackDemo.aspx.cs" Inherits="CallbackDemo" %&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)&lt;head runat="server"&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)    &lt;title&gt;CallbackDemo&lt;/title&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)    &lt;script type="text/javascript"&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedBlock.gif)        function GetServerDateTime(context) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            &lt;%= ClientScript.GetCallbackEventReference(this, "", "ReceiveServerData", "")%&gt;;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedBlockEnd.gif)        }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedBlock.gif)        function ReceiveServerData(rValue) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            document.getElementById("ResultsSpan").innerHTML = rValue;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedBlockEnd.gif)        }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)    &lt;/script&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)&lt;/head&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)&lt;body&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)    &lt;form id="form1" runat="server"&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)    &lt;div&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)        &lt;input id="btnSubmit" type="button" value="现在时间是" onclick="GetServerDateTime(ResultsSpan)" /&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)        &lt;br /&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)        &lt;span id="ResultsSpan" runat="server"&gt;&lt;/span&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)    &lt;/div&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)    &lt;/form&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)&lt;/body&gt;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)&lt;/html&gt;

 

 .aspx.cs源代码：

&lt;!-- &lt;br /&gt; &lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware) &lt;br /&gt;http://www.CodeHighlighter.com/ &lt;br /&gt; &lt;br /&gt;--&gt;![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)using System;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)using System.Collections.Generic;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)using System.Web;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)using System.Web.UI;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)using System.Web.UI.WebControls;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)public partial class CallbackDemo : System.Web.UI.Page,ICallbackEventHandler  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedBlock.gif)...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    protected void Page\_Load(object sender, EventArgs e)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    public void RaiseCallbackEvent(String eventArgument)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)          
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    public String GetCallbackResult()  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        return DateTime.Now.ToString();  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedBlockEnd.gif)}

 

    演示中客户端注册的脚本函数：&lt;%= ClientScript.GetCallbackEventReference(this, "", "ReceiveServerData", "")%&gt;;。这句动态生成一个客户端函数，该函数包含对来自GetCallbackEventReference方法的返回值的调用。ClientScriptManager.GetCallbackEventReference方法有4个重载函数，上面这个方法中，"this"是处理客户端回调的服务器控件，它必须实现ICallbackEventHandler 接口并提供RaiseCallbackEvent 方法，它的类型是System.Web.UI.Control。第二个参数是从客户端脚本传递给服务器的一个参数，它是String类型的。第三个函数是客户端事件处理程序的名称，它接收成功的服务器事件的结果，这里把回调结果返回给JS中的ReceiveServerData()方法。最后一个参数是启动回调之前在客户端计算的客户端脚本。脚本的结果传回客户端事件处理程序。

    JS方法：

&lt;!-- &lt;br /&gt; &lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware) &lt;br /&gt;http://www.CodeHighlighter.com/ &lt;br /&gt; &lt;br /&gt;--&gt;![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedBlock.gif)function ReceiveServerData(rValue) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    document.getElementById("ResultsSpan").innerHTML = rValue;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedBlockEnd.gif)}

 

 

接收服务器事件的结果，并将结果呈现出来。

    而服务器端的RaiseCallbackEvent()方法没有内容，因为这里是最简单的演示，我们没有回调参数，如果有回调参数在这个方法中处理。GetCallbackResult()则是返回当前的系统时间。

    在VS中测试刚才的DEMO，发现会在浏览器源代码中自动生成一段这样的代码：

&lt;!-- &lt;br /&gt; &lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware) &lt;br /&gt;http://www.CodeHighlighter.com/ &lt;br /&gt; &lt;br /&gt;--&gt;![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/None.gif)&lt;script src="/Callback/WebResource.axd?d=EsUKgUC2lEyf3iKipjXhYw2&amp;t=633655516704843750" type="text/javascript"&gt;&lt;/script&gt;

 

 

这个DEMO产生的WebResource.axd有21KB大小，测试了一下，所有的文件都是一样的体积。它是在这个文件中创建了AJAX请求：

&lt;!-- &lt;br /&gt; &lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware) &lt;br /&gt;http://www.CodeHighlighter.com/ &lt;br /&gt; &lt;br /&gt;--&gt;

![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedBlock.gif)function WebForm\_DoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    var postData = \_\_theFormPostData +  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)                "\_\_CALLBACKID=" + WebForm\_EncodeCallback(eventTarget) +  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)                "&\_\_CALLBACKPARAM=" + WebForm\_EncodeCallback(eventArgument);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    if (theForm\["\_\_EVENTVALIDATION"]) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        postData += "&\_\_EVENTVALIDATION=" + WebForm\_EncodeCallback(theForm\["\_\_EVENTVALIDATION"].value);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    var xmlRequest,e;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    try ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequest = new XMLHttpRequest();  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    catch(e) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)        try ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)        }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)        catch(e) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)        }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    var setRequestHeaderMethodExists = true;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    try ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        setRequestHeaderMethodExists = (xmlRequest && xmlRequest.setRequestHeader);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    catch(e) ...{}  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    var callback = new Object();  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    callback.eventCallback = eventCallback;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    callback.context = context;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    callback.errorCallback = errorCallback;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    callback.async = useAsync;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    var callbackIndex = WebForm\_FillFirstAvailableSlot(\_\_pendingCallbacks, callback);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    if (!useAsync) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)        if (\_\_synchronousCallBackIndex != -1) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            \_\_pendingCallbacks\[\_\_synchronousCallBackIndex] = null;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)        }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        \_\_synchronousCallBackIndex = callbackIndex;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    if (setRequestHeaderMethodExists) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequest.onreadystatechange = WebForm\_CallbackComplete;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        callback.xmlRequest = xmlRequest;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequest.open("POST", theForm.action, true);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequest.send(postData);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        return;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    callback.xmlRequest = new Object();  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    var callbackFrameID = "\_\_CALLBACKFRAME" + callbackIndex;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)    var xmlRequestFrame = document.frames\[callbackFrameID];  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    if (!xmlRequestFrame) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame = document.createElement("IFRAME");  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame.width = "1";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame.height = "1";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame.frameBorder = "0";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame.id = callbackFrameID;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame.name = callbackFrameID;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame.style.position = "absolute";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame.style.top = "-100px"  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame.style.left = "-100px";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)        try ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)            if (callBackFrameUrl) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)                xmlRequestFrame.src = callBackFrameUrl;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)            }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)        }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)        catch(e) ...{}  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        document.body.appendChild(xmlRequestFrame);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)    }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)    var interval = window.setInterval(function() ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)        xmlRequestFrame = document.frames\[callbackFrameID];  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)        if (xmlRequestFrame && xmlRequestFrame.document) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            window.clearInterval(interval);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            xmlRequestFrame.document.write("");  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            xmlRequestFrame.document.close();  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            xmlRequestFrame.document.write('&lt;html&gt;&lt;body&gt;&lt;form method="post"&gt;&lt;input type="hidden" name="\_\_CALLBACKLOADSCRIPT" value="t"&gt;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;');  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            xmlRequestFrame.document.close();  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            xmlRequestFrame.document.forms\[0].action = theForm.action;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            var count = \_\_theFormPostCollection.length;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            var element;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)            for (var i = 0; i &lt; count; i++) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)                element = \_\_theFormPostCollection\[i];  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)                if (element) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)                    var fieldElement = xmlRequestFrame.document.createElement("INPUT");  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)                    fieldElement.type = "hidden";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)                    fieldElement.name = element.name;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)                    fieldElement.value = element.value;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)                    xmlRequestFrame.document.forms\[0].appendChild(fieldElement);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)                }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockEnd.gif)            }  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            var callbackIdFieldElement = xmlRequestFrame.document.createElement("INPUT");  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            callbackIdFieldElement.type = "hidden";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            callbackIdFieldElement.name = "\_\_CALLBACKID";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            callbackIdFieldElement.value = eventTarget;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            xmlRequestFrame.document.forms\[0].appendChild(callbackIdFieldElement);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            var callbackParamFieldElement = xmlRequestFrame.document.createElement("INPUT");  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            callbackParamFieldElement.type = "hidden";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            callbackParamFieldElement.name = "\_\_CALLBACKPARAM";  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            callbackParamFieldElement.value = eventArgument;  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)            xmlRequestFrame.document.forms\[0].appendChild(callbackParamFieldElement);  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ExpandedSubBlockStart.gif)![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/ContractedSubBlock.gif)            if (theForm\["\_\_EVENTVALIDATION"]) ...{  
![](http://blog.moozi.net/editors/fckeditor/editor/plugins/mzplugins/images/InBlock.gif)