var xmlHttp; //创建的一个全局的变量
function createxmlhttp(){
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}; //给这个全局附直
window.onload = function(){
createxmlhttp();
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText)
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true)
xmlHttp.send(null);
};
//在这个以上的地方 ie ff 下都是对的了 都可以alert出来数据
//在这个以下的地方 Set方法绑定在一个按纽上 ff下可以弹出数据(不管安多少次) ie却不行 怎么办了?
function Set(){
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText)
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true)
xmlHttp.send(null)
};
function createxmlhttp(){
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}; //给这个全局附直
window.onload = function(){
createxmlhttp();
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText)
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true)
xmlHttp.send(null);
};
//在这个以上的地方 ie ff 下都是对的了 都可以alert出来数据
//在这个以下的地方 Set方法绑定在一个按纽上 ff下可以弹出数据(不管安多少次) ie却不行 怎么办了?
function Set(){
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText)
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true)
xmlHttp.send(null)
};
解决方案 »
- 【急】屏蔽了右键的前提下,如何得到网页模式窗口中的源文件
- 关于window.open打开网页问题
- js图片滚动问题
- jQuery错误
- showModelessDialog子窗口的执行完毕后自动关闭并刷新父窗体
- 高手帮忙看下,这段JS哪错,我感觉没错啊!!
- 高手帮帮忙啊
- 在javascript里用这样var today=new day()得到的时间,可不可以用mon=today.getMonth()来得到月份,以及其它的年、日等?如果可以,为什
- 如何判断*.js文件已经下载完成?完成后再执行相关操作?
- 哪里有用层实现的tab页阿?
- js 中有没有替换String.format("%05d",“”)的方法吗??~跪求~~急等!!
- href中使用window.open,怎样使用js变量
var xmlHttp; //创建的一个全局的变量
function createxmlhttp(){
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}; //给这个全局附直
window.onload = function(){
createxmlhttp();
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText)
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true)
xmlHttp.send(null);
};
//在这个以上的地方 ie ff 下都是对的了 都可以alert出来数据
//在这个以下的地方 Set方法绑定在一个按纽上 ff下可以弹出数据(不管安多少次) ie却不行 怎么办了?
function Set(){
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText)
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true)
xmlHttp.send(null)
};
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText)
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true)
xmlHttp.send(null)
}; set 可能会与关键字冲突,改一个,还有这个函数仅仅定义好象没有被调用呢,试看...
html页面就这么一个元素了
ie下不行 确切的说是ie6(别的版本不知道)
ff chrome都是可以的
-------------------------------------------------
换成其他的名字也不行 如 换成 change为什么ff chrome下却可以了
<input>
...
alert("LZ先把函数换成这个看看可不可以!");
}
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true);
xmlHttp.send(null);
}这样呢?
alert('xbb')
xmlHttp.onreadystatechange=function(){
alert('xxxx')
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText)
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true)
xmlHttp.send(null)
alert('xx')
};
里面就 alert('xxxx')不能执行
function Set(){
createxmlhttp();
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText);
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true);
xmlHttp.send(null);
}
这样多不好啊 哈哈
听说是缓存的问题
不过还是没试出来
xmlHttp.abort();//停止当前请求
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4)
alert(xmlHttp.responseText);
};
xmlHttp.open("GET","GetDataService?method=getProvinceByCountry&countryID=86",true);
xmlHttp.send(null);
}
其实LZ加上这句也可以,而且可以防止重复提交呢,呵呵可能是浏览器的BUG吧