日期:2014-05-16  浏览次数:20434 次

ajax不调用后台代码

   <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="addType()" />

    <script type="text/javascript" >
        function addType() {
            var getType = prompt("Please input Type", '');
            if (getType!=null) {
                var XmlHttp = createXMLHttpResponse(); 
                if (XmlHttp) { 
                    XmlHttp.onreadystatechange = interactWithServer(XmlHttp); 
                    XmlHttp.open("GET", " interactWithAJAX.aspx?action=addType&type=" + getType,true); 
                    XmlHttp.send();
                }
                else {
                    alert("XMLHttpResponse is null");
                }
            }
            else {
                alert("Type not be save");
            }
        }
        
        function createXMLHttpResponse (){ 
            if(window.ActiveXObject )
                return new ActiveXObject("Microsoft.XMLHTTP");
            else(window.XMLHttpRequest)
                return new XMLHttpRequest();