Colorbox with .post() request

4.4k Views Asked by At

I am trying to use open a colorbox after a jquery .post(); request, loading the page that I posted to but I have an issue. I am opening a new instance of the page, which did not receive the posted data.

$.post( "/shop/checkout.php", { shipping: shipping },
  function(data) {
    $.colorbox({top: 50,scrolling:false,preloading:false,href:"/shop/checkout.php"});
  }
);

I have used firebug, and the post is successful with the correct data. However, when I load checkout.php within the colorbox, it is an instance of checkout.php that did not receive the data.

1

There are 1 best solutions below

0
On

You already have the data in post callback, just provide the data to colorbox using html option. You don't have to set href option.

$.post( "/shop/checkout.php", { shipping: shipping },
  function(data) {
     $.colorbox({ 
         top: 50,
         scrolling: false,
         preloading: false,
         html: data
     });
  }
);