Sending email with CodeIgniter and JQuery! |
[eluser]AdonisSMU[/eluser]
I am trying to send a form via JQuery’s ajax function and CodeIgniter. I pass the data from the Ajax function to the appropriate script… I am not sure how to go about validation in this case…
[eluser]Sbioko[/eluser]
Please describe your problem in more informative way. Provide some code and then I will help you!
[eluser]AdonisSMU[/eluser]
What I want to do is use the jQuery Ajax Function to send an email with CodeIgniter. That's what I want to do. Code: $.ajax({
[eluser]AdonisSMU[/eluser]
What I am not sure about is how I am able to send my variables to the function inside the appropriate class and then send the error messages back. How can I do some form validation with the form validation class if I am sending the variables via ajax?
[eluser]Sbioko[/eluser]
It is very easy :-) You must remove your Ajax controller and put method, which you are using for Ajax in your main controller. To recieve responses from php functions you need simply echo them.
[eluser]Ben Edmunds[/eluser]
In this example ajax/ajax_join_us would be called and the data you specified is available in post, ie: Code: $this->input->post('survivor_name'); And whatever the ajax_join_us method echo's is available as the results variable in your javascript.
[eluser]AdonisSMU[/eluser]
So the function I want to send them to is the ajax_join_us function inside the Ajax controller. What address would need to go here ( http://oaklawnbowling.com/NEW_Site/index...ax_join_us ) instead ? Based on what you are saying it should be http://oaklawnbowling.com/NEW_Site/index...ax_join_us ???
[eluser]AdonisSMU[/eluser]
[quote author="Ben Edmunds" date="1262654870"]In this example ajax/ajax_join_us would be called and the data you specified is available in post, ie: Code: $this->input->post('survivor_name'); And whatever the ajax_join_us method echo's is available as the results variable in your javascript.[/quote] Now how would I go about form validation with the form validation helper? Would I just do it like normal? i.e. Code: $this->form_validation->set_rules('username', 'Username', 'required');
[eluser]AdonisSMU[/eluser]
[quote author="Demedes" date="1262656600"]No, what is the name of your main controller?[/quote] site ajax is the controller I want to handle the forms. |
Welcome Guest, Not a member yet? Register Sign In |