PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$SelectedCountry = $_GET['value'];
include("connection.php");
OpenConnection();
$result = mysql_query("Select state from statemaster where countryid = (select countryid from countrymaster where country = '" . $SelectedCountry . "')");
return $result;
?>
When the above code returns result, how to get in Ajax xmlhttp.responseText
<script language="javascript" type="text/javascript" src="prototype.js"></script>
<script language="javascript">
function getAjaxResult()
{
var URL = "ajaxresult.php" //provide your php script path
new Ajax.Request
(
URL,
{
method: "get",
onSuccess: function (response)
{
$("resultContainerID").innerHTML = response.responseText; //resultContainerID is the container where you want show your result e.g. <div id="resultContainerID"><!--Your result will come here--></div>
}
}
);
}
</script>
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("ddState").innerHTML=xmlhttp.responseText;
var xmlDoc=xmlhttp.responseXML.documentElement;
document.getElementById("ddState").innerHTML=
xmlDoc.getElementsByTagName("ddState")[0].childNodes[0].nodeValue;
}
}
function showUser(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="FillState.php";
url=url+"?q="+str;
getAjaxResult(url);
}
function getAjaxResult(URL)
{
document.write(URL);
new Ajax.Request
(
URL,
{
method: "get",
onSuccess: function (response)
{
$("ddState").innerHTML = response.responseText;
}
}
);
}
Please note the ShowUser function above gets response from this line: