各位大大,请看下面的情况:
设在a.asp 中有以下段落:response.write "<td align='right'>AccessoriesState</td><td align='left'><input name='config_state' type='hidden' value='0'><input name='config_state_name' type='text' value='' size=6 readonly><a href=""javascript:configstate('accessories');"">ConfigState</a></td>"
response.write "<td align='right'>Supplier</td><td align='left'><input name='config_supplier' type='hidden' value='0'><input name='config_supplier_name' type='text' value='' size=6 readonly><a href=""javascript:configsupplier('accessories');"">ConfigSupplier</a></td>"
response.write "<span id='content1' display: none;>Select...</span>"
在包含的javascript在publicfunc.js中有
var xmlhttp; try
{
xmhhttp=new ActiveXObjec("Msxml2.XMLHTTP");
}
catch (e)
{
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
try{
xmlhttp=new XMLHttpRequest();
}
catch (e){}
}
}function configstate(webpage){
var content=document.getElementById("content1");
document.getElementById("content1").style.display="none";
content.style.display="inline";
xmlhttp.onreadystatechange=function()
{
if(4==xmlhttp.readyState)
{
if(200==xmlhttp.status)
{
document.getElementById("content1").innerHTML=xmlhttp.responseText;
}
else
{
alert(xmlhttp.status);
}
}
}
var url="selectsupplier.asp?modkey=selectstate&webpage="+webpage;
xmlhttp.open("get",url);
xmlhttp.send(null);
}
function configsupplier(fromweb){
var content=document.getElementById("content1");
content.style.display="inline";
xmlhttp.onreadystatechange=function()
{
if(4==xmlhttp.readyState)
{
if(200==xmlhttp.status)
{
document.getElementById("content1").innerHTML=xmlhttp.responseText;
}
else
{
alert(xmlhttp.status);
}
}
}
var url="selectsupplier.asp?modkey=selectsupplier&webpage="+fromweb;
xmlhttp.open("get",url);
xmlhttp.send(null);
}
相关的页面处理代码就不贴了,我每次点击a.asp中的任一的动作时都可以成功运行,但运行第二个动作时就发生错误,无任何提示性的。
请问下各位大侠们,我的代码中是不是xmlhttp对象不能重复使用造成的?如果是要怎么改?如果不是又要怎么改可以使得二个动作或者更多的动作都可以实现?
设在a.asp 中有以下段落:response.write "<td align='right'>AccessoriesState</td><td align='left'><input name='config_state' type='hidden' value='0'><input name='config_state_name' type='text' value='' size=6 readonly><a href=""javascript:configstate('accessories');"">ConfigState</a></td>"
response.write "<td align='right'>Supplier</td><td align='left'><input name='config_supplier' type='hidden' value='0'><input name='config_supplier_name' type='text' value='' size=6 readonly><a href=""javascript:configsupplier('accessories');"">ConfigSupplier</a></td>"
response.write "<span id='content1' display: none;>Select...</span>"
在包含的javascript在publicfunc.js中有
var xmlhttp; try
{
xmhhttp=new ActiveXObjec("Msxml2.XMLHTTP");
}
catch (e)
{
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
try{
xmlhttp=new XMLHttpRequest();
}
catch (e){}
}
}function configstate(webpage){
var content=document.getElementById("content1");
document.getElementById("content1").style.display="none";
content.style.display="inline";
xmlhttp.onreadystatechange=function()
{
if(4==xmlhttp.readyState)
{
if(200==xmlhttp.status)
{
document.getElementById("content1").innerHTML=xmlhttp.responseText;
}
else
{
alert(xmlhttp.status);
}
}
}
var url="selectsupplier.asp?modkey=selectstate&webpage="+webpage;
xmlhttp.open("get",url);
xmlhttp.send(null);
}
function configsupplier(fromweb){
var content=document.getElementById("content1");
content.style.display="inline";
xmlhttp.onreadystatechange=function()
{
if(4==xmlhttp.readyState)
{
if(200==xmlhttp.status)
{
document.getElementById("content1").innerHTML=xmlhttp.responseText;
}
else
{
alert(xmlhttp.status);
}
}
}
var url="selectsupplier.asp?modkey=selectsupplier&webpage="+fromweb;
xmlhttp.open("get",url);
xmlhttp.send(null);
}
相关的页面处理代码就不贴了,我每次点击a.asp中的任一的动作时都可以成功运行,但运行第二个动作时就发生错误,无任何提示性的。
请问下各位大侠们,我的代码中是不是xmlhttp对象不能重复使用造成的?如果是要怎么改?如果不是又要怎么改可以使得二个动作或者更多的动作都可以实现?
function createXMLHttpRequest(){
try
{
xmhhttp=new ActiveXObjec("Msxml2.XMLHTTP");
}
catch (e)
{
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
try{
xmlhttp=new XMLHttpRequest();
}
catch (e){}
}
}
}在执行ajax前调用一下这个方法