I have a little problem with my first jQuery script… It makes an AJAX post to a controller that check if an Email exists or not in the database. If it don’t exist, the controller returns a string to the Javascript. I did check with Firebug and everything is working. The AJAX gets the string back, but the callback function is not being executed. It should display the string in an alert box, but it doesn’t.
My view file is:
My email_check.js file is:
$('#email').blur(function() {
$.post(
'http://www.mysite.com/login/check/',
{ email: $('#email').val() },
function(data,textStatus) {
alert("Data Loaded: "+data);
$('#login_msg').html(data);
},
'json'
};
});It should show the alert() above, but the callback function is not executed. May I am returning an invalid data type to it? I did this script based in an example in the manual.
The controller it calls is:
class Check extends Controller {
function Check() {
parent::Controller();
$this->load->model('users/profiles_model','profiles');
}
function index() {
$email=$this->input->post('email');
$result=$this->profiles->get_user_by_email($email);
if(!$result) {
echo 'Invalid E-mail address: '.$email;
}
}
}The string is being returned, I can see it with Firebug.