Welcome Guest, Not a member yet? Register   Sign In
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('','');
                }




Theme © iAndrew 2016 - Forum software by © MyBB