i have two input fields for example(A and B) whose values are coming through database, the value of field B depend upon the value of A. I am using ajax call to change the values of input field B. here is my code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
function ajaxfunction(parent)
{
$.ajax({
url: 'http://localhost/test/process.php',
data: { vall : parent },
success: function(data) {
$("#sub").html(data);
}
});
}
</script>
</head>
<body>
<select onchange="ajaxfunction(this.value)">
<?php
$q= mysql_query("select * from tab1");
while ($row= mysql_fetch_array($q)){
$name= $row['name'];
echo '
<option value="'.$name.'"> '.$name.' </option>
';
}
?>
</select>
<select id="sub"></select>
</body>
</html>
and my process.php was:
$e =$_GET['vall'];
echo $e;
$result = mysql_query("SELECT * FROM tab2 WHERE name = '".$e."' ");
while(($data = mysql_fetch_array($result)) !== false)
echo '<option value="', $data['id'],'">', $data['lname'],'</option>'
It is working fine for me. Now the problem is I am working in classes and I want to get the value in a function, Now i have the following structure of process.php
class location{
public function getlocation($e)
{
$sql="SELECT * FROM tab2 WHERE name = '".$e."'";
return $this->objConnect->GetData($sql);
}
public function GetallpropertyFeatured(){
$sql="select * from sale_property WHERE category='Featured' AND accept_status='Active' ORDER BY property_id DESC ";
return $this->objConnect->GetData($sql);
}//for showing all propery on the base of recent status.
public function GetallpropertyRecent(){
$sql="select * from sale_property WHERE category='Recent' AND accept_status='Active' ORDER BY property_id DESC ";
return $this->objConnect->GetData($sql);
}//for showing all propery on the base of trending status.
public function GetallpropertyTrending(){
$sql="select * from sale_property WHERE category='Trending' AND accept_status='Active' ORDER BY property_id DESC ";
return $this->objConnect->GetData($sql);
}
//for Getting propery on the base of featured status.
public function GetpropertyByFeatured(){
$sql="select * from sale_property WHERE category='Featured' AND accept_status='Active' ORDER BY property_id DESC ";
return $this->objConnect->GetData($sql);
}
//for Getting propery on the base of latest status.
public function GetpropertyByRecent()
{
$sql="select * from sale_property WHERE category='Recent' AND accept_status='Active' ORDER BY property_id DESC ";
return $this->objConnect->GetData($sql);
}
//for Getting propery on the base of trending status.
public function GetpropertyByTrending()
{
$sql="select * from sale_property WHERE category='Trending' AND accept_status='Active' ORDER BY property_id DESC ";
return $this->objConnect->GetData($sql);
}
//for Getting propery on the base of File status.
public function GetpropertyByFile()
{
$sql="select * from sale_property WHERE type='File' AND accept_status='Active' ORDER BY property_id DESC ";
return $this->objConnect->GetData($sql);
}
public function GetallpropertyByFile()
{
$sql="select * from sale_property WHERE type='File' AND accept_status='Active' ORDER BY property_id DESC ";
return $this->objConnect->GetData($sql);
}
public function getimages($propertyid)
{
$sql="select images from images_property where property_id=$propertyid";
return $this->objConnect->GetData($sql);
}
// for getting images of property
public function getimg($propertyid)
{
$sql="select images from images_property where property_id=$propertyid limit 0,3";
return $this->objConnect->GetData($sql);
}
}
so what should be the url in ajax how I pass value in ajax now, right now i am passing like this :
$.ajax({
url: 'http://localhost/test/process.php',
data: { vall : parent },
Regards