Ajax无法在客户端域中工作。但是在我的域中工作,也在localhost中工作

时间:2010-04-22 13:11:51

标签: ajax

function getXMLHTTP() { 

    var xmlhttp=false;  

    try
    {
        xmlhttp=new XMLHttpRequest();
    }
    catch(e)    {       
        try{            
            xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e){
            try{
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e1){
                xmlhttp=false;
            }
        }
    }

    return xmlhttp;
}

function display_state(countryIdTEXT) 
{   
    var countryId = countryIdTEXT;
     alert(countryId);
    if(countryId !='')
    {   
         var strURL="select_state.php?con_name="+countryId;//alert(cate_id);
         alert(strURL);
         var req = getXMLHTTP();

        if (req) {

            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                    // only if "OK"

                        document.getElementById('content').innerHTML=req.responseText;                      

                }               
            }           
            req.open("GET", strURL, true);
            req.send(null);
        }       
    }
}

HTML

<select name="country" id="country"  onchange="display_state(this.value)" style="width:225px;" >
<option value="selectCountry">Select Country</option>
{section name=view loop=$country}
<option value="{$country[view].Ident}" {if $country[view].Ident eq $smarty.request.country } selected="selected" {/if} >{$country[view].Country_name}</option>
{/section}
</select>

1 个答案:

答案 0 :(得分:0)

忘记为templates_c 文件夹授予777权限。现在它运作良好..