ajax 응용

4464 단어 ajax 응용
Web Tools--Ajax Version

    일기예보:  
  IP 주소 조회:  
핸드폰 귀속 조회:  
            chgBtnStyle();        //다른 브 라 우 저 에서 지정 한 id 대상 function getObj(objectID){가 져 오기    return document.all ? document.all[objID] : document.getElementById(objID);}var req;//xmlrequest 대상 function createXHR(){사용 하기    try {        req = new ActiveXObject("Msxml2.XMLHTTP");    }    catch (e) {        try {            req = new ActiveXObject("Microsoft.XMLHTTP");        }        catch (E) {            req = false;        }    }    if (!req && typeof XMLHttpRequest != "undefined") {        req = new XMLHttpRequest();    }}function getWeather() {    createXHR();    req.open("GET", "weather.asp?City=" + getObj("Weather").value, true);    req.send();    req.onreadystatechange = handleStateChange1;}function handleStateChange1() {    if (req.readyState<4){getObj("Disp_Weather").innerText="["+getObj("Weather").value+"]날씨 상황 을 조회 중 입 니 다..."}    else if (req.readyState == 4 && req.status == 200) {        getObj("Disp_Weather").innerText = req.responseText;    } else {        getObj("Disp_Weather").innerText = "\u67e5\u8be2\u8fc7\u7a0b\u51fa\u73b0\u8fc7\u7a0b\uff0c\u8bf7\u91cd\u8bd5\u6216\u8054\u7cfb\u7ba1\u7406\u5458\uff01";    }}function checkip() {    var ipArray, ip, j;    ip = getObj("Ip").value;    if (/[^\d\.]/.test(ip)) {        return false;    }    ipArray = ip.split(".");    if (ipArray.length != 4) {        return false;    }    for (var i = 0; i < 4; i++) {        if (ipArray[i].length == 0 || ipArray[i] > 255) {            return false;        }    }    return true;}function getIp() {    if (checkip()) {        createXHR();        req.open("GET", "IpSearch.asp?IP=" + getObj("Ip").value, true);        req.send();        req.onreadystatechange = handleStateChange;    } else {        getObj("Disp_IPArea").innerText = "\u8fd4\u56de\u9519\u8bef\uff1a\u4e0d\u662f\u6b63\u786e\u7684ip";    }}function handleStateChange() {    if (req.readyState<4){getObj("Disp_IPArea").innerText="ip["+getObj("Ip").value+"]를 조회 하고 있 습 니 다..."}    else if (req.readyState == 4 && req.status == 200) {        getObj("Disp_IPArea").innerText = req.responseText;    } else {        getObj("Disp_IPArea").innerText = "\u67e5\u8be2\u8fc7\u7a0b\u51fa\u73b0\u9519\u8bef\uff0c\u8bf7\u91cd\u8bd5\u6216\u8054\u7cfb\u7ba1\u7406\u5458\uff01";    }}function checkMobile() {    var sMobile = getObj("Mobile").value;    if (!(/^13[0-9]\d{4,8}$/.test(sMobile))) {        return false;    }    return true;}function getMobile() {    if (checkMobile()) {        createXHR();        req.open("GET", "MobileSearch.asp?Mobile=" + getObj("Mobile").value, true);        req.send();        req.onreadystatechange = handleStateChange2;    } else {        getObj("Disp_MobileArea").innerText = "\u8fd4\u56de\u9519\u8bef\uff1a\u4e0d\u662f\u5b8c\u6574\u768411\u4f4d\u624b\u673a\u53f7\u6216\u8005\u6b63\u786e\u7684\u624b\u673a\u53f7\u524d\u4e03\u4f4d";    }}function handleStateChange2() {    if (req.readyState<4){getObj("Disp_MobileArea").innerText="휴대폰 번호 조회 중 입 니 다["+getObj("Mobile").value+"]..."}    else if (req.readyState == 4 && req.status == 200) {        getObj("Disp_MobileArea").innerText = req.responseText;    } else {        getObj("Disp_MobileArea").innerText = "\u67e5\u8be2\u8fc7\u7a0b\u51fa\u73b0\u9519\u8bef\uff0c\u8bf7\u91cd\u8bd5\u6216\u8054\u7cfb\u7ba1\u7406\u5458\uff01";    }}
function chgBtnStyle(){    var btn=document.getElementsByTagName("input")    for(var i=0;i

좋은 웹페이지 즐겨찾기