Ajax Aspx頁面請求

   function LoadImage(ElementID, id) {
            //ElementID <img>的ID
            var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");  //WebClient
            if (!xmlhttp) {
                alert("創建xmlhttp對象異常");
                return false;
            }
            var url = "GetImage.ashx?ID=" + id + "&ts" + new Date();
            xmlhttp.open("POST", "GetImage.ashx?ID=" + id + "&ts" + new Date(), false);
            xmlhttp.onreadystatechange = function event() {
                if (xmlhttp.readystate == 4) {
                    if (xmlhttp.status == 200) {
                        document.getElementById(ElementID).src = url;
                    }
                    else {
                        alert("Ajax返回Error");
                    }
                }
            }
            xmlhttp.send();
        }
原文地址:https://www.cnblogs.com/siri/p/2975120.html