More Games - PAINONE

Android games

sites.google.com

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<script type="text/javascript">
    var request = null;
    function createRequest() {
        try {
            request = new XMLHttpRequest();
        } catch (trymicrosoft) {
            try {
                request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (othermicrosoft) {
                try {
                    request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (failed) {
                    request = null;
                }
            }
        }
 
        if (request == null) {
            alert("너가 사용하는 브라우저는 도대체 뭐냐..??");
        }
    }
 
    /* Get 방식 */
    function Get_Search() {
        createRequest()
        var id = document.getElementById("id").value;
        var passwd = document.getElementById("passwd").value;
        var url = "test.php?id=" + id + "&passwd=" + passwd;
 
        request.open("GET", url, true);
        request.onreadystatechange = updatePage;
        request.send(null);
    }
 
    /* Post 방식 */
    function Post_Search() {
        createRequest()
        var id = document.getElementById("id").value;
        var passwd = document.getElementById("passwd").value;
        var url = "test.php";
 
        request.open("POST", url, true); //"POST"
        request.onreadystatechange = updatePage;
        /* 요청헤더 추가 필수!!! */
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send("id=" + id + "&passwd=" + passwd);
    }
 
    function updatePage() {
        if (request.readyState == 4) {
            if(request.status == 200) {
                document.getElementById('Content').innerHTML = request.responseText;
            } else {
                alert("서버에러!!");
            }
        }
    }
 
</script>
<div id="form">  
<input id="id" type="text">   
<input id="passwd" value="" type="password">   
<input onclick="Post_Search()" ;="" value="보내기" type="button">
</div>
<div id="Conten" t=""></div>
 
 
 
<!--?php
    echo "<p-->get id : ".$_GET[id]."<p></p>";
    echo "<p>get passwd : ".$_GET[passwd]."</p>";
    echo "<p>post id : ".$_POST[id]."</p>";
    echo "<p>post passwd : ".$_POST[passwd]."</p>";
?>

'Language > Ajax' 카테고리의 다른 글

Ajax 간단한 예제소스  (0) 2010.05.23
 

More Games - PAINONE

Android games

sites.google.com

 

More Games - PAINONE

Android games

sites.google.com

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var request = null;
function createRequest() {
    try {
        request = new XMLHttpRequest();
    } catch (trymicrosoft) {
        try {
            request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (othermicrosoft) {
            try {
                request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (failed) {
                request = null;
            }
        }
    }
 
    if (request == null) {
        alert("너가 사용하는 브라우저는 도대체 뭐냐..??");
    }
}
 
function getBoardsSold() {
    createRequest()
    var content = document.getElementById("content");
    var contentStr = getText(content);
    var url = "test.php?ContentStr=" + contentStr;
 
    request.open("GET", url, true);
    request.onreadystatechange = updatePage;
    request.send(null);
}
 
function updatePage() {
    if (request.readyState == 4) {
        if(request.status == 200) {
            var newContent = request.responseText;
            var contenttStr = document.getElementById("Content");
            replaceText(contentStr, newContent);
        } else {
            alert("서버에러!!");
        }
    }
}
 
function replaceText(el, text) {
    if (el != null) {
        clearText(el);
        var newNode = document.createTextNode(text);
        el.appendChild(newNode);
    }
}
 
function clearText(el) {
    if (el != null) {
        if (el.childNodes) {
            for (var i = 0; i < el.childNodes.length; i++) {
                var childNode = el.childNodes[i];
                el.removeChild(childNode);
            }
        }
    }
}
 
function getText(el) {
    var text = "";
    if (el != null) {
        if (el.childNodes) {
            for (var i = 0; i < el.childNodes.length; i++) {
                var childNode = el.childNodes[i];
                if (childNode.nodeValue != null) {
                    text = text + childNode.nodeValue;
                }
            }
        }
    }
    return text;
}

'Language > Ajax' 카테고리의 다른 글

GET방식 POST방식  (0) 2010.05.23
 

More Games - PAINONE

Android games

sites.google.com

+ Recent posts