Js|web
<!--
Using methods, call SendRequest (URL, method, HttpMethod, params) directly
Parameter description: url--access address; method--call service method; httpmethod--Pass method, default post;params--parameter or information to be passed;
Multi-parameter Use & connection, post method tested;
Attention!
Successful transmission echo function for xmlresponse (), please add it before this JS reference, otherwise invalid, echo content for Req.responsetext, default for synchronization.
Functions Getxmlrequester () {//This function is to establish the XMLHTTP component and may not be available with IE low version, see MSDN;
var xmlhttp_request = false;
try{
if (window. ActiveXObject) {
for (var i = 5; i; i--) {
try{
if (i = = 2) {
Xmlhttp_request = new ActiveXObject ("Microsoft.XMLHTTP");
}else{
Xmlhttp_request = new ActiveXObject ("msxml2.xmlhttp." + i + ". 0");
Xmlhttp_request.setrequestheader ("Content-type", "text/xml;charset=utf-8");
}
break;
catch (e) {
Xmlhttp_request = false;
}
}
}else if (window. XMLHttpRequest) {
Xmlhttp_request = new XMLHttpRequest ();
if (Xmlhttp_request.overridemimetype) {
Xmlhttp_request.overridemimetype (' Text/xml ');
}
}
}catch (e) {
Xmlhttp_request = false;
Alert ("Sorry your browser version is too low, please use it after updating.") ");
}
return xmlhttp_request;
}
var req;
function SendRequest (URL, method, HttpMethod, params) {
URL + = "/" + method;
if (! HttpMethod) {
HttpMethod = "POST";
}
req = Getxmlrequester (); Building components
if (req) {
Req.onreadystatechange = processreqchange;//Call Process monitoring function
Req.open (HttpMethod, URL, true);
Req.setrequestheader ("Host", "202.115.138.116");
Req.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
Req.setrequestheader ("Content-length", params.length);
Req.send (params); Send data parameters
}
}
function Processreqchange () {
Monitor data delivery.
if (req.readystate = = 4) {
if (Req.status = = 200) {
Xmlresponse (); Connect OK perform output function out ()
else {//Throw error
Alert ("Unable to connect to server properly, error: \ n" +
req.statustext+ ":" +req.status);
}
}
}
-->
<HTML>
<HEAD>
<meta http-equiv= ' content-type ' content= ' text/html;charset=gb2312 ' >
<meta name= ' GEMERATPR ' content= ' Network programmer Companion (lshdic) >
<TITLE></TITLE>
<script language= ' Jscript ' >
<!--
function Xmlresponse () {
Message.value = Req.responsetext;
}
-->
</SCRIPT>
<script language=jscript src= ' file:///C:/Documents and settings/losingrose/desktop/js/httprequest.js ' ></script >
</HEAD>
<BODY>
<textarea id= ' send ' value= ' rows= ' 2 ' style= ' width:100; ' ></textarea>
<input type= ' button ' value= ' sdfsdf ' onclick= ' SendRequest ("Http://202.115.138.116/ChatWebService/Service.asmx", "DataSet", "POST", "a=" +send.value+ "&b=2&c=3453"); '/>
<textarea id= ' message ' value= ' rows= ' 8 ' style= ' width:500; ' ></textarea>
</BODY>
</HTML>