zou iemand mij kunnen helpen met het volgende.

mijn success van ajax ontvangt geen data kan iemand mij even de juiste kant ophelpen
code staat hier onder.

Mvg ralph

indexModel

class indexModel extends model
{
function __construct(){
parent::__construct();
}

public function getAllContacts(){

$this->db->setTable('contacten');
$this->db->setQuery('SELECT * FROM `contacten` JOIN `type` ON contacten.type_id = type.type_id');

$result = $this->db->select();

return $result;
}
}?>

indexController
<?php

class indexController extends controller
{
function __construct()
{
parent::__construct();

require 'model/indexModel.php';

// laad de model
$this->model = new indexModel();

//laad de view
$this->view->render('index');

}

/*
* getAllContacts
*
* @param sort string.
*
* @return results mixxed array
*/

public function getAllContacts()
{
echo 'test';
$result = $this->model->getAllContacts();


return json_encode($result);
}
}


indexView
<?php
<div id="overzicht"><!-- hier komt het overzicht --></div>
?>

global.js

<?php
$(function(){

//overzicht.

//ajax calls
$('#overzicht').ready(function(){

$.ajax({
type : 'POST',
url :'localhost/index/getAllContacts',
success:function(data) {
console.log(data);
$('#overzicht').html(data);
}
});
})

//wijzigen
//login
$('#logIn').click(function(){
var bot = $('#bot').val();


if(bot === undefined){
var user = $('#gebruikersnaam').val();
var pass = $('#wachtwoord').val();
//ajaxcall
$.ajax({
type : 'POST',
url :'localhost/login/validateLogin',
data:{
user :user,
pass: pass,
},
success:function(data) {
console.log(data);
//window.location.replace('index');
},
});
}else{
return false;
}
})
//functies

});
?>
console.log(data); Gaat nooit werken omdat het een array of een object is. Het moet dus altijd
console.log(data[0].id) worden of whatever
oke ik zal is kijken


[size=xsmall]Toevoeging op 16/12/2014 16:21:13:[/size]

sws krijg ik nu ook geen console.log meer XD
Dit is hoe ik het doe. Ik geef altijd een status terug: {"status":"success", ..... }


            $.ajax({
                url: "/volledig/pad/naar/pagina",
                type: 'POST',
                data: { name:"frank", pass:"1234" },
                cache: false,
                dataType: 'json',
                success: function(data, textStatus, jqXHR)
                {
                        if(data.status == 'success')
                        {
                            console.log('status = succes!');
                        }
                        else
                        {
                                // Handle errors here
                                console.log('ERRORS: ' + data.error);
                        }
                },
                error: function(jqXHR, textStatus, errorThrown)
                {
                        console.log('ERRORS: ' + textStatus);
                }
            });
jQuery documentatie

Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

Reageren