开发者

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


  1. Does your DB table 'thread' have rows in them?

  2. Is something else in the controller causing the AJAX request to fail? Execute the controller directly and see if it echos what you expect

  3. Does a DIV with the id 'divvertemas' exist in your view layer?

  4. Install firebug and look at the XHR request/output and any Javascript errors

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜