why my ajax method dont reach my controller method?, and never show the results of select
I am developing a forum mvc oop (no frameworks), but I got problems (for listing all the threads in the forum) , I have an ajax method (button submit onclick - HTML in the view), I hope you can help me,my ajax method never pass t开发者_Go百科o my controller method (doesnt list anything in the for loop), even though I create an instance of my class in the model, I dont know why doesnt list my threads??
This is my button input type="submit" value="Show threads" name="btn" id="txtthreads" onClick="showThreads()"/>
ajax method
function showThreads(){
//var page="../Controller/ControllerShowThread.php";
ajax3=new objetoajax();
ajax3.open("POST", "../Controller/ControllerShowThread.php");
ajax3.onreadystatechange=function(){
if(ajax3.readyState<4){
document.getElementById("divvertemas").innerHTML="Executing.....";
}
if(ajax3.readyState==4){
document.getElementById("divvertemas").innerHTML=ajax3.responseText;
}
}
ajax3.send(null);
}
Controller
$object = new Thread();
$result = $object->showThreads();
foreach($result as $array){
echo "result";
}
?>
Model
function showThreads(){
$query = "SELECT * FROM thread";
return $this->objConexion->executeQuery();
}
I hope you can help me
Does your DB table 'thread' have rows in them?
Is something else in the controller causing the AJAX request to fail? Execute the controller directly and see if it echos what you expect
Does a DIV with the id 'divvertemas' exist in your view layer?
Install firebug and look at the XHR request/output and any Javascript errors
精彩评论