File: PBWebEasyXMLHttpReqeustToDIV.html
Size: 4527
Date: Sat, 08 Dec 2007 15:37:10 +0100
Type: html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <META HTTP-EQUIV="PowerSiteData" NAME="SERVERLANGUAGE" CONTENT="JavaScript">
    <TITLE>PB Web Easy using XMLHttpRequest and &lt;div&gt</TITLE>
    <META http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <META content="PB9.0.3.8004" name="GENERATOR">
    <LINK href="pbwebeasy.css" type="text/css" rel="stylesheet"> 
    <SCRIPT language="JavaScript">
 
function InitForm () {
shref = location.href;
servstart = shref.indexOf("//") + 2;
servend = shref.indexOf("/",servstart);
var server = shref.substring(servstart, servend);
append = shref.indexOf("/",servend+1)
document.getElementById ('inpapplication').value = shref.substring(servend+1, append);
document.getElementById ('inpserverurl').value = "http://"+server+"/cgi-bin/pwe.exe";
}
function xmlhttpGet(strMethod, strURL, strQuery, strResult) {
 var myHttpRequest = null;
 var self = this;
 if ( strMethod != "POST" ) strMethod = "GET"
 
// Mozilla, Opera, Safari sowie Internet Explorer 7
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
    myHttpRequest = new XMLHttpRequest();
    if (myHttpRequest.overrideMimeType) myHttpRequest.overrideMimeType('text/xml');
  } else if (window.ActiveXObject) { // IE
    try {
      myHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        myHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
    }
  }
 
  if (myHttpRequest) {
    myHttpRequest.onreadystatechange = function () {
            if (myHttpRequest.readyState == 4) {
                document.getElementById(strResult).innerHTML = myHttpRequest.responseText;
            }   
    };
    if (strMethod == 'GET') {
        strURL = strURL + "?" + strQuery;
        strQuery = null;
    }
    myHttpRequest.open(strMethod, strURL );
    if (strMethod == 'POST' ) 
        myHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 
    myHttpRequest.send(strQuery); 
  }
 
  }
function geturl () {
    var form     = document.forms['f1'];
    strURL =  form.inpserverurl.value + "/" + form.inpapplication.value + "/" + form.inpclass.value + "/" + form.inpmethod.value ;
    return strURL;
}
function getquerystring() {
    var form     = document.forms['f1'];
    qstr = form.inpquerystring.value;  
    return qstr;
}
function getviaxmlhttp() {
    xmlhttpGet("GET" , geturl (), getquerystring(), "result" );
}
</SCRIPT>
</HEAD>
<BODY language="JavaScript" bgColor="white" onload="InitForm()" PSPARAMS="">
<H1>PB Web Easy using XMLHttpRequest and &lt;div&gt;</H1>
<DIV id="Formular">
    <FORM name="f1">
        <TABLE id="TABLE1" style="WIDTH: 320px; HEIGHT: 138px" cellPadding="2" border="1" frame="void">
            <TBODY id="TBODY1">
            <TR id="TR1" vAlign="top" align="left">
                <TD id="TD1">ServerURL:</TD>
                <TD id="TD2">
                    <INPUT style="WIDTH: 230px; HEIGHT: 20px" tabIndex="1" size="33" value="<none>" name="inpserverurl" id="inpserverurl">
                </TD>
            </TR>
            <TR id="TR2">
                <TD id="TD3">Applicaton:</TD>
                <TD id="TD4">
                    <INPUT class="" style="WIDTH: 229px; HEIGHT: 20px" tabIndex="2" size="32" value="pbwebeasy" name="<none>" id="inpapplication">
                </TD>
            </TR>
            <TR id="TR3">
                <TD id="TD5">Object:</TD>
                <TD id="TD6">
                    <INPUT style="WIDTH: 229px; HEIGHT: 20px" tabIndex="3" size="31" value="cgienv" name="inpclass" id="inpclass">
                </TD>
            </TR>
            <TR id="TR4">
                <TD id="TD7">Function:</TD>
                <TD id="TD8">
                    <INPUT style="WIDTH: 230px; HEIGHT: 20px" size="32" value="of_printcgienv" name="inpmethod" id="inpmethod">
                </TD>
            </TR>
            <TR>
                <TD>QueryString:</TD>
                <TD>
                    <INPUT style="WIDTH: 229px; HEIGHT: 20px" size="32" value="A=B&C=D" name="inpquerystring" id="inpquerystring">
                </TD>
            </TR>
            <TR id="TR5">
                <TD id="TD9">Action</TD>
                <TD id="TD10">
                    <INPUT language="JavaScript" style="WIDTH: 55px; HEIGHT: 22px" onclick="getviaxmlhttp()" type="button" size="42" value="Go">
                </TD>
            </TR>
            </TBODY>
        </TABLE>
    </FORM>
</DIV>
<DIV id="result"></DIV>
<DIV id="footer">This a footer</DIV>
</DIV>
</BODY>
</HTML>