62,041
社区成员
发帖
与我相关
我的任务
分享
//以XML求取ListBox4的数据
function XmlPost4(obj)
{
var svalue = obj.value;
var webFileUrl = "?xiangid=" + svalue;
var result = "";
var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
xmlHttp.open("POST", webFileUrl, false);
xmlHttp.send("");
result = xmlHttp.responseText;
if(result != "")
{
document.all("ListBox4").length=0;
var piArray = result.split(",");
for(var i=0;i<piArray.length;i++)
{
var ary1 = piArray[i].toString().split("|");
document.all("ListBox4").options.add(new Option(ary1[1].toString(),ary1[0].toString()));
}
}
else
{
alert(result);
}
}
C# code//以XML求取ListBox4的数据
function XmlPost4(obj)
{
var svalue = obj.value;//传进来的参数
var webFileUrl = "?xiangid=" + svalue;//连接地址
var result = "";
var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");//XMLHttpRequest 对象
xmlHttp.open("POST", webFileUrl, false);//xmlHttp打开connection
xmlHttp.send("");// 发送请求
result = xmlHttp.responseText;//获得返回值
//把返回值写入ListBox
if(result != "")
{
document.all("ListBox4").len…
function XmlPost4(obj)
{
var svalue = obj.value;
var webFileUrl = "?xiangid=" + svalue;
var result = "";
var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
xmlHttp.open("POST", webFileUrl, false);
xmlHttp.send("");
result = xmlHttp.responseText;
//以上是使用xmlhttp将svalue的值提交到指定页面,这个页面经过处理传入的值后输出一个字符串
//responseText的内容就是,里面的内容是通过","分割的
if(result != "")
{
document.all("ListBox4").length=0;
var piArray = result.split(",");
for(var i=0;i<piArray.length;i++)
{
var ary1 = piArray[i].toString().split("|");
document.all("ListBox4").options.add(new Option(ary1[1].toString(),ary1[0].toString()));
}
//以上代码是分割通过“,”responseText,然后将结果添加到listbox4里面
}
else
{
alert(result);
}
}