In my page I have the following code
hostadd.php
<script language="javascript" type="text/javascript">
function getXMLHTTP() { //function to return the xml http object
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 getState(countryId) {
var strURL="findState.php?country="+countryId;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
document.getElementById('statediv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
</script>
<div style="margin-left: 51px;">State:
<select name="country" id="country" onChange="getState(this.value)" style="margin-left: -3px;">
<option ></option>
<?php $qr = mysql_query("select * from ctm_state ");
while($data= mysql_fetch_array($qr))
{?>
<option value="<?php echo $data['id']; ?>"><?php echo $data['state']; ?></option>
<?php } ?>
</select>
</div>
findstate.php
<? $country=intval($_GET['country']);
include("../config/config.php");
$query="SELECT id,location FROM ctm_locationname WHERE stateid='$country'";
echo $query;
$result=mysql_query($query);
if($result)
{
echo "success";
}
else
{
echo "cant fetch";
}
?>
<div style=""> location:<select name="state" id="state">
<option></option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value=<?=$row['location']?>><?=$row['location']?></option>
<? } ?>
</select></div>
But it shows the error of “There was problem using xml http request” . I cant find what mistake is done by me. Anyone can help me to solve this problem
I pressume your
var strURL="findState.php?country="+countryId;is not proper.Check your browser error console, you can see errors there.
If it is showing 404 page not found, It is because your strURL is not proper check the spelling or path.