C#怎样实现http请求webservice返回xml数据
展开全部
WebService 返回的数据本身就是XML
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
使用AJAX
function getXMLHTTP() {
var xmlhttp;
if (window.ActiveXObject)
{
//IE
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTP");
}
}
else
{
//FireFox
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
var XMLHttpObj;
function GetDOMCity1()
{
var city = document.getElementById("ctl00_ContentPlaceHolder1_ddl_Province").value;
XMLHttpObj = getXMLHTTP();
XMLHttpObj.open("POST", "WebService.asmx/ShowCity", false);
XMLHttpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
XMLHttpObj.onreadystatechange = proc;
XMLHttpObj.send("provinceId=" + city);
}
function proc()
{
if (XMLHttpObj.readyState == 4)
{
if (XMLHttpObj.status == 200)
{
alert(XMLHttpObj.responsXML);
}
}
}
function getXMLHTTP() {
var xmlhttp;
if (window.ActiveXObject)
{
//IE
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTP");
}
}
else
{
//FireFox
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
var XMLHttpObj;
function GetDOMCity1()
{
var city = document.getElementById("ctl00_ContentPlaceHolder1_ddl_Province").value;
XMLHttpObj = getXMLHTTP();
XMLHttpObj.open("POST", "WebService.asmx/ShowCity", false);
XMLHttpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
XMLHttpObj.onreadystatechange = proc;
XMLHttpObj.send("provinceId=" + city);
}
function proc()
{
if (XMLHttpObj.readyState == 4)
{
if (XMLHttpObj.status == 200)
{
alert(XMLHttpObj.responsXML);
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询