Welcome Guest, Not a member yet? Register   Sign In
Sending email with CodeIgniter and JQuery!
#1

[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…
#2

[eluser]Sbioko[/eluser]
Please describe your problem in more informative way. Provide some code and then I will help you!
#3

[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({
                    type: 'post',
                    url : 'http://oaklawnbowling.com/NEW_Site/index.php/ajax/ajax_join_us',
                    data: 'survivor_name=' + survivor_name +
                          '&survivor;_address=' + survivor_address +
                          '&survivor;_home_phone=' + survivor_home_phone +
                          '&survivor;_email=' + survivor_email +
                          '&your;_name=' + your_name +
                          '&your;_address=' + your_address +
                          '&your;_city=' + your_city +
                          '&your;_state=' + your_state +
                          '&your;_zip=' + your_zip +
                          '&your;_home_phone=' + your_home_phone +
                          '&your;_email=' + your_email +
                          '&comments;=' + comments,
                    success: function(results) {
                        
                       // not sure how to handle this.....
                            
                    } // success
                
                }); // end ajax
#4

[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?
#5

[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.
#6

[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.
#7

[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 ???
#8

[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');
#9

[eluser]Sbioko[/eluser]
No, what is the name of your main controller?
#10

[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.




Theme © iAndrew 2016 - Forum software by © MyBB