DIR : /home/kozerus/public_html/ajaxget.html

/home/kozerus/public_html

<html>
<head>
<title>Ajax GET HTTP Request</title>
 
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"> 
function ajaxRequest(){
     var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]; //activeX versions to check for in IE
     if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
      for (var i=0; i<activexmodes.length; i++){
       try{
        return new ActiveXObject(activexmodes[i]);
       }
       catch(e){
        //suppress error
       }
      }
     }
     else if (window.XMLHttpRequest) // if Mozilla, Safari etc
      return new XMLHttpRequest();
     else
      return false;
}
 
function ajaxget(){
    var mygetrequest=new ajaxRequest();
    mygetrequest.onreadystatechange=function(){
     if (mygetrequest.readyState==4){
      if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
       document.getElementById("result").innerHTML = mygetrequest.responseText;
      }
      else{
       alert("An error has occured making the request");
      }
     }
    }
    var userId = encodeURIComponent(document.getElementById("userId").value);
    var password = encodeURIComponent(document.getElementById("password").value);
    mygetrequest.open("GET", "http://localhost:8080/AjaxTest/Login?userId="+userId+"&password="+password, true);
    mygetrequest.send(null);
}
 
</SCRIPT>
</head>
<body>
 
    <form method="get" action="">
        <table>
            <tr>
                <td>User Id:</td>
                <td><input type="text" id="userId" name="userId" size="30" />
                </td>
            </tr>
            <tr>
                <td>Password:</td>
                <td><input type="password" id="password" name="password"
                    size="30" />
                </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td><input type="button" value="submit" onClick="ajaxget()" />
                </td>
            </tr>
        </table>
    </form>
 
    <div id="result"></div>
</body>
</html>
//


koh5_pano



Your browser does not support the HTML5 canvas element.


Drag mouse to navigate.

Navigation





17.Aug.2010, Martin Wengenmayer