Is it possible to pass variable in ajax call?
$(document).on('click','#Quote_create_value',function(){
$template = $(this).val();
$.ajax({
type : 'GET',
url : '../../../protected/config/ajax.php',
data:"function=result($template)",
success : function(response){
$("#Quote_template_value").html(response);
}
});
});
In ajax.php, I have that fuction.I want to call result function in the ajax.php I am not getting the respose.
if(isset($_GET['function'])) {
if($_GET['function'] == 'templateDropDown') {
$query = "select * from quote where template IS NOT NULL";
$result = mysql_query($query, $con);
while ($row = mysql_fetch_assoc($result)) {
echo '<option value="'.$row['template'].'">' . $row['template'] . '</option>';
}
mysql_free_result($result);
}
elseif($_GET['function'] == 'result($template)') {
$query = "select * from template where templateName=$template";
$result = mysql_query($query,$con);
while ($row = mysql_fetch_assoc($result)) {
echo $row['unitcost'];
}
}
}