国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
JS調(diào)用web service的通用函數(shù)

http://www.pin5i.com/showtopic-22580.html

調(diào)用:

RequestByPost(method,variable,value,url,_Namespace)

 

method:web service的方法名

variableweb service的方法的變量名數(shù)組

valueweb service的方法的變量的值的數(shù)組

url:請(qǐng)求的地址(asmx文件地址)

_Namespaceweb service的命名空間

 

<script language="javascript" type="text/javascript">

// <!CDATA[

//define

var xmlhttp;

var value=new Array();

var variable=new Array();

//Show Response MSG.

function handleStateChange()

{

    var h=document.getElementById("Label1");

    if(xmlhttp.readyState==4)

    {

        if(xmlhttp.status==200)

        {

            alert(xmlhttp.responseText);

            h.innerHTML=xmlhttp.responseText;

            //h.innerHTML=xmlhttp.responseXML;

        }

        else if(xmlhttp.status==404)

        {

            h.innerHTML="<br>找不到請(qǐng)求的服務(wù)器資源!";

        }

    }

    else if(xmlhttp.readyState==0)

    {

        h.innerHTML="<br>未初始化!";

    }

    else if(xmlhttp.readyState==1)

    {

        h.innerHTML="<br>正在加載……!";

    }

    else if(xmlhttp.readyState==2)

    {

        h.innerHTML="<br>已經(jīng)加載完成!";

    }

    else if(xmlhttp.readyState==3)

    {

        h.innerHTML="<br>正在和服務(wù)器交互";

    }

    else

    {

        h.innerHTML=xmlhttp.responseXML;

}

}

//Get Request Data's length

 

function getlen(str)

{

var bytesCount=0;

for (var i = 0; i < str.length; i++)

{

var c = str.charAt(i);

if (/^[\u0000-\u00ff]$/.test(c))  //匹配雙字節(jié)

      {

bytesCount += 1;

}

else

{

bytesCount += 2;

}

}

return bytesCount;

} 

//Create XMLHttpRequest Object

  function createXMLHttpRequest()

{

    if(window.ActiveXObject)

    {

        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

    }

    else if(window.XMLHttpRequst)

    {

        xmlhttp=new XMLHttpRequest();

    }

} 

//send Request By HTTP POST

function RequestByPost(method,variable,value,url,_Namespace)

{

createXMLHttpRequest();

var data;

data = '<?xml version="1.0" encoding="utf-8"?>';

data = data + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="'">http://schemas.xmlsoap.org/soap/envelope/">';

data = data + '<soap:Body>';

data = data + '<'+method+' xmlns="'+_Namespace+'">';

for(var i=0;i<variable.length;i++)

{    data = data + '<'+variable[i]+'>'+value[i]+'</'+variable[i]+'>';

}

data = data + '</'+method+'>';

data = data + '</soap:Body>';

data = data + '</soap:Envelope>';

xmlhttp.onreadystatechange=handleStateChange;

xmlhttp.Open("POST",url, true);

xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");

xmlhttp.SetRequestHeader ("Content-Length",getlen(data));

xmlhttp.SetRequestHeader ("SOAPAction",_Namespace+method);

xmlhttp.Send(data);

alert(data);

}

//CallHelloWorld!

function SayHello_onclick() {

//alert(document.getElementById('YourName').value);

  RequestByPost("HelloWorld",new Array("msg"),new Array(document.getElementById('YourName').value),"WebService.asmx","localhost/");

}

//WeatherReport Test:

function Button2_onclick() {

RequestByPost("getWeatherbyCityName",new Array("theCityName"),new Array(document.getElementById('CityName').value),"http://www.webxml.com.cn/WebServices/WeatherWebService.asmx","http://WebXml.com.cn/");

}

// ]]>

</script>

默認(rèn)的命名空間名字應(yīng)該以“/”結(jié)尾

 
另:相關(guān)連接請(qǐng)參考:
在.net中集成Mootools做圖片動(dòng)態(tài)翻頁
http://kb.cnblogs.com/a/1414420/
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
簡(jiǎn)單ajax實(shí)例,最具兼容性,簡(jiǎn)單介紹ajax運(yùn)行模式,根據(jù)此自認(rèn)為最好的模式可以設(shè)計(jì)出很好的應(yīng)用。
java,javascript 內(nèi)連取數(shù)據(jù)
用XMLHttpRequest和struts實(shí)現(xiàn)AJAX(轉(zhuǎn))
XMLHTTPRequest對(duì)象來進(jìn)行AJAX的異步數(shù)據(jù)交互
【javascript】ajax 基礎(chǔ)
用原生JS寫根據(jù)時(shí)間顯示問候語
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服