标题:AJAX 兼容问题 求解决 在火狐下正常显示 IE下AJAX返回结果输出不到指定位置 ...
取消只看楼主
kxun
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-2-7
 问题点数:0 回复次数:0 
AJAX 兼容问题 求解决 在火狐下正常显示 IE下AJAX返回结果输出不到指定位置.代码如下:
前台页面:
<script type="text/javascript">
function createRequest(){
    var request;
    if(window.XMLHttpRequest){ // For Mozilla, Safari, ...
        request = new XMLHttpRequest();
    } else if(window.ActiveXObject){ // For Internet Explorer
         try {
            request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
           try {
             request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
    }
    return request;
}
function getcity(ctid,tid){
    var ajax=createRequest();
    var url = "aja.php?cid="+tid+"&ccc="+ctid;
    alert(url);
    //location=url;
    ajax.open("GET",url,true);
    ajax.onreadystatechange = function () {
        if (ajax.readyState == 4 && ajax.status==200) {
            if(window.XMLHttpRequest){
            document.getElementById(ctid).innerHTML=ajax.responseText;}
            else
            {
            document.getElementById(ctid).outerHTML=ajax.responseText;}
            document.getElementById(ctid).style.display='inline';
            if(ctid=="typeidj")
            {
                document.getElementById("typeidh").style.display='none';
                document.getElementById("typeid").style.display='none';
            }else if(ctid=="typeidh")
            {
                document.getElementById("typeid").style.display='none';
            }
            //alert(ajax.responseText);
        }
    }
    ajax.send(null);
}
</script>
<select name='typeidk' style='width:200' onchange=\"getcity('typeidj',document.form1.typeidk.value)\">
<option value='0' selected>所有栏目...</option>
<option value='1‘>aaa</option></select>
 <select name='typeidj' style='width:200; display:none' id="typeidj" onchange="getcity('typeidh',document.form1.typeidj.value)">
</select>      
----php处理页

<?php
require_once(dirname(__FILE__)."/config.php");
require_once(DEDEINC."/typelink.class.php");
$cid=$_GET['cid'];
$pp=$_GET['ccc'];
$tl = new TypeLink($cid);
$tl->dsql->SetQuery("SELECT * FROM `dede_arctype` where reid=$cid order by sortrank asc");
$tl->dsql->Execute();
if($pp=="typeidj") {
//echo"<select name='typeidj' style='width:150px;' id='typeidj' onchange=\"getcity('typeidh',document.form1.typeidj.value)\">";
echo" <option value='-1' selected='selected'>所有区域...</option>";
while($row = $dsql->GetObject())
{
   echo "<option value='".$row->id."'>".$row->typename."</option>\r\n";
}
//echo "</select>";
}else if($pp=="typeidh") {
//echo"<select name='typeidh' style='width:150px;' id='typeidh' onchange='getcity('typeid',document.form1.typeidh.value)'>";
echo" <option value='-2' selected='selected'>所有平台...</option>";
while($row = $dsql->GetObject())
{
   echo "<option value='".$row->id."'>".$row->typename."</option>\r\n";
}
//echo "</select>";
}else if($pp=="typeid") {
//echo"<select name='typeid' style='width:150px;' id='typeid'>";
echo" <option value='-3' selected='selected'>所有栏目...</option>";
while($row = $dsql->GetObject())
{
   echo "<option value='".$row->id."'>".$row->typename."</option>\r\n";
}
//echo "</select>";
}
?>
搜索更多相关主题的帖子: javascript 前台 function Internet Explorer 
2012-02-07 14:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-360536-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.099218 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved