Answer the question
In order to leave comments, you need to log in
How to organize the storage of intermediate data for multiple ajax calls?
Hello! Please help with advice on how best to store intermediate data. The meaning is that in the online store on the product selection page (in my case, fabric), when you click on the product thumbnail, an ajax request is sent to the server with parameters to select from the database:
$(document).ready(function() {
$('#select-menu').find('a').click(function() {
var itemData = $(this).attr('href');
$.ajax({
type: "POST",
url: "cloth_data.php",
data: itemData,
cache: true,
success:
function processData(data) {
$(".ajax-loader").show().css("opacity", 1);
var img = $(data).find("figure").find("img").css("opacity", 0);
var clothImg = $(data).find(".clothImg").css("opacity", 0);
var title = $(data).find(".clothTitle");
var mnSelect = $(data).find(".mainSelect").attr('href');
var price = $(data).find(".itemPrice");
var debug = $(data).find(".debugItm");
img.on("load", function () {
setTimeout(function() {
$(".ajax-loader").css("opacity", 0);
}, 200);
setTimeout(function() {
$(".ajax-loader").hide();
}, 500);
$(this).css("opacity", 1);
});
clothImg.on("load", function () {
$(this).css("opacity", 1);
});
$("#item-wrapper").find(".main").replaceWith(img);
$(".price").show();
$(".clothImg").replaceWith(clothImg);
$(".itemPrice").replaceWith(price);
$(".clothTitle").replaceWith(title);
$(".selectBlock").show();
$(".mainSelect").attr('href', mnSelect);
$(".debugItm").replaceWith(debug);
}
});
return false;
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question