首页 > 代码库 > JavaScript的Ajax请求示例

JavaScript的Ajax请求示例

 //创建XMLHttpRequest对象 
            var request = false;
            try {
                request = new XMLHttpRequest();
            }
            catch (trymicrosoft) {
                try {
                    request = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (othermicrosoft) {
                    try {
                        request = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    catch (failed) {
                        request = false;
                    }
                }
            }
            if (!request) alert("Error initializing XMLHttpRequest!");
            request.open("POST", "../Ashx/Upload.ashx?" + $F("upfile"), true);
            request.onreadystatechange = function () { };
            request.send(null);

JavaScript的Ajax请求示例