Welcome Guest, Not a member yet? Register   Sign In
Form submit with Ajax problem
#1

[eluser]Cgull[/eluser]
Hello,

I have a view with a form in it and some links.

Every link is calling another form with ajax.

When the second form is submitted, I want it to close, and display a success message.

The first form should stay on the screen with the details that the user filled in.

I tried a few ways but each way caused me a problem.

Right now, what I am doing is when the second form is submitted:

Code:
function addOrderDets()
{
$.ajax({
   type: "POST",
   url: "/orders/index.php/processOrder/addOrderDets",
   success: function(data){
    
    $('#orderDetsResult').show();
  }
});
}

And in the processOrder controller:

Code:
function addOrderDets()
  {
  $this->load->model('mOrderDets');
  $products = $this->mOrderDets->addOrderDets();
  redirect('home');
  }

Of course, redirect does not work, since it refreshes the page and all the data the user capture is gone.

But how do I keep the data?

I also tried this way:

Code:
function addOrderDets()
{
$.ajax({
   type: "POST",
   url: "/orders/index.php/processOrder/addOrderDets",
   success: function(data){
   if(data)  
     $('#orderDetsResult').show();
  }
});
}

and the controller:

Code:
function addOrderDets()
  {
  $this->load->model('mOrderDets');
  $products = $this->mOrderDets->addOrderDets();
  echo "1";
  }

Then it just goes to page:
Code:
http://localhost/orders/processOrder/addOrderDets

and displays: 1.

Any help will be very appriciated. Smile




Theme © iAndrew 2016 - Forum software by © MyBB