I have been trying to retrieve data via AJAX. I can't seem to be able to 'read' what was sent to me by PHP. Here's the code
$('create_course').addEvent('submit', function(e){
e.stop();
flash.setStyle('display', 'none');
this.set('send', {
onComplete: function(resp){
if ($chk(resp))
{
console.log($type(resp));
if (resp == 'true')
{
flash.set('html', resp);
flash.reveal();
}
elseif (resp == 'false')
{
$$('div.information').dissolve();
$$('div.options').reveal();
}
}
}
}).send();
});
A different action will happen when I receive a true and a different one on false.
This was the code.
if (is_ajax())
{
if ($this->form_validation->run('course_create') === TRUE)
{
$course = array(
'name' => $this->input->post('name'),
'description' => $this->input->post('desc'),
'price' => $this->input->post('price')
);
if ($this->course->create($course))
{
echo 'true';
}
else
{
echo 'false';
}
}
else
{
echo validation_errors('<div class="message error"><p>', '</p></div>');
}
}
Note: I've modified the php and js to just read if there's a response. So this php and js is what is used to be. My point is how do I 'read' the return value in Mootools/JS.