mtree java script not working in IE
One of my client had a form developed in component Mosets Tree
. In the form when you select a main category it automatically displays the subcategories. Now the issue is; I had to hide some code to stop displaying a few things, after that the java script which was displaying subcategories after we select the main category is not working in IE.
code:
< script >
var xmlhttp;
function stateChanged(){
if (xmlhttp.readyState==4) {
document.getElementById("subCatId").innerHTML = xmlhttp.responseText;
}
}
function fnGetSubCategory() {
xmlhttp = GetXmlHttpObject();
var new_cat_id = document.getElementById("new_cat_id").value;
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return true;
}
var url="ps.php?cat_id="+new_cat_id;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function GetXmlHttpObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
< /script>
It is working fine in all other browsers.
Thanks in advance.
尝试使用以下代码创建对象xmlHttp:
function createXmlHttpRequestObject(){
var xmlHttp;
try{
xmlHttp = new XMLHttpRequest();
}
catch (e) {
// If its IE 6 or other version before
var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP');
// We try all versions
for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++){
try {
//Try creating xmlHttp object
xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
}
catch (e){
xmlHttp = false;
}
}
}
// If object doesn't exist sends error
if (!xmlHttp){
alert("Error creating XMLHttpRequest object");
}
else{
return xmlHttp;
}
}
链接地址: http://www.djcxy.com/p/48220.html
上一篇: 以与JSON嵌套相同的方式触摸关联模型
下一篇: mtree java脚本不能在IE中工作