Welcome Guest, Not a member yet? Register   Sign In
Codeigniter AJAX validation email form
#3

[eluser]LuckyFella73[/eluser]
Regarding your js success function:
You have to echo out soemthing to return information
to your ja function. Use "echo" or "die()". I use
to "die()" a json encoded result, that way you can
send the matching message to your js function having
it more flexible.

Code:
// Controller:

// for example
$result = array(
'msg' => 'You mail was send',
'validation_flag'=> 0, // you can define levels for each possible situation (success, error, info about missing input ...
);

// built this array depending on your validation and what kind of feedback you want to give to the user

die(json_encode($result));


// in your js (success function) switch through 'validation_flag' and
do the needed actions like show message or whatever

Btw.: it can't be bad to use the csrf protection


Messages In This Thread
Codeigniter AJAX validation email form - by El Forum - 11-15-2012, 03:23 AM
Codeigniter AJAX validation email form - by El Forum - 11-15-2012, 03:52 AM
Codeigniter AJAX validation email form - by El Forum - 11-15-2012, 06:39 AM
Codeigniter AJAX validation email form - by El Forum - 11-15-2012, 10:20 AM
Codeigniter AJAX validation email form - by El Forum - 11-16-2012, 02:46 AM
Codeigniter AJAX validation email form - by El Forum - 11-16-2012, 03:18 AM
Codeigniter AJAX validation email form - by El Forum - 11-16-2012, 03:32 AM
Codeigniter AJAX validation email form - by El Forum - 11-16-2012, 03:40 AM
Codeigniter AJAX validation email form - by El Forum - 11-16-2012, 03:46 AM
Codeigniter AJAX validation email form - by El Forum - 11-16-2012, 04:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB