I am using CodeIgniter ..I can't access the method from the controller
I have this script in my view
<script>
function showHint(str){
if (str.length==0){
document.getElementById("txtHint").innerHTML="";
return;
}
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax/ajaxSearch",true);
xmlhttp.send();
}
</script>
and i have a controller named ajax with a method ajaxSearch()
public function ajaxSearch(){
echo "received";
}
Folder Structure
htdocs/
AjaxTry/
AjaxSearchingMVC/
application/
controller/
ajax.php //controller
ajaxSearch() //method
views/
view_ajax.php // here is where the script is written
What could be the possible problem here?