I'm new to ajax. I'm trying to call get_mother method through ajax in my form textbox change event. I want to show results in datalist. below is the code i have used.
class ChildApplication extends Application{
function __construct(){
$this->login_required();
}
function get_mother(){
$mother = $_POST['mother_name'];
$mother = '%'.$mother.'%';
$db=$this->get_dbo();
$sql = "SELECT * FROM tbl_mother WHERE `mother_fname` LIKE ? ";
$results = $db->load_result($sql,array($mother));
return $results;
}
function get_child($mother){
//statements
}
}
My script is:
$(document).ready(function(){
$("#mother_name").keyup(function(event){
event.preventDefault();
var mother = $("#mother_name").val();
$.ajax({
type: 'POST',
url: 'applications/child/child.php',
data: dataString,
dataType: 'json',
success: function(){
alert("pass");
},
error: function(){
alert("error");
}
});
});
});
none of alerts are displayed. please help me to solve the problem