Posted on 25/07/2014 13:46:38
Hi Nuno,
When making an ajax cart we have a page with no layout and the cart module attached, and after adding an item to the cart we redirect the to that page and reads the response with jquery:
$('.js-basket-add').submit(function (e) {
var url = $('#json-cart-url').val();
if (url) {
e.preventDefault();
var input = $(this).serialize() + "&Redirect=default.aspx?id=" + url;
$.ajax(
{
url: "Default.aspx?id=" + url,
type: "POST",
data: input,
dataType: "html",
cache: false,
traditional: true,
success: function (data, textStatus, jqXHR) {
$(".js-minicart").html($(data).html());
$(".js-minicart").show();
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
});
return false;
}
});
This is the content of the "no layout"-template:
<!--@DwContent(contentmain)-->
<!--@If(1=2)-->
<div class="dwcontent" id="contentmain" title="Main content" data-settings="template:ModuleOnly.cshtml"></div>
<!--@EndIf-->
Hope this can help you?
Best regards, Anders