EDIT:
I found the problem with my evaluation not working. All the text being returned from my codeIgniter functions has a space before it, so while I saw "success" it was actually " success". I don't know why it is, but I can certainly work with that.
As for the next step - opening a new view - Donny's answer was perfect!
I am using CodeIgniter for an application with JQuery for my AJAX library. I'm just learning the AJAX stuff, so I'm probably missing something basic here...
The following code if for a login form.
The goal is this -use an ajax call on the form submit so I can validate the errors and provide error messages on screen without web page refreshes. I'm doing all my validation with the CodeIgniter form_validation class.
My codeigniter function returns a text value - either an appropriate error message or the word "success." I want to evaluate the text value, and if it says "success", call another ajax function to load the needed CodeIgniter function that will load home page for logged in users.
Right now everything works in the code below until I get to the statement "if data=='success'".
Why would that return false when I know it is true because the on screen message displays "success"?
$(document).ready(function() {
$('#registration_form').submit(function(e) {
e.preventDefault();
$.post("login", {
email : $('#email').val(),
password : $('#password').val()
}, function(data) {
$('#message').text(data);
if (data == "success") {
alert(data);
post("landingpage");
}
});
});
});