0
Inside the model I have a series of negotiations to show the final result.
//CONTROLLER
public function index(){
$this->view->render("views/index.php");
}
public function read(){
$data = array();
$data['id'] = $_POST['id'];
$this->model->showAlgo($data);
}
//MODEL
public function showAlgo($data){
//Faz um select com o $data['id'] e retorna uma a table já montada
$resultadoDaQuery = "<table><tr><td>".$resultado['algumacolunadobanco']."</td></tr></table>";
echo json_encode($resultadoDaQuery);
}
script:
$.ajax({
url: "nome/read",
type: "POST",
success: function(dados){
//monta os dados aqui e envia pro html via jquery
},
error: function(){}
});
- what is the correct way to assemble the result?
- can do this in the model as in the example above and send directly to ajax (in
success
)? - or you must mount the table inside the ajax (in the function
success
)?