How can I send back to user the response message using AJAX forms?

#1
[eluser]Unknown[/eluser]
I am trying to implement in my forms based on this tutorial, help tutorial look at here ..

here everything works fine, how can i redirect another page to say successfully saved or on the same page???

Code:
if (is_ajax() AND $this->form_validation->run() === TRUE)
                {
                    //echo "Registration Successful";
                    if ($this->hostings_model->check_unique() > 0 ) {
                            $this->session->set_flashdata( 'message', array( 'title' => 'Record exists', 'content' => 'Hosting is already exists, Try new', 'type' => 'message' ));
                                    redirect('hostings/hostings_add', $data);    
                    }
                
                    // add then
                    $result = $this->hostings_model->add();                
                    if ($result)
                    {
                        $this->session->set_flashdata( 'message', array( 'title' => 'Hosting created', 'content' => 'Hosting details has been saved sucessfully', 'type' => 'message' ));
                        redirect('hostings/main');                            
                    
                    } else
                    {
                        $this->session->set_flashdata( 'message', array( 'title' => 'Hosting error', 'content' => 'Hosting could not be saved', 'type' => 'error' ));
                        redirect('hostings/main');
                    }
                }
                else
                {
                    echo validation_errors('','');
                }


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.