Answer the question
In order to leave comments, you need to log in
How to pass value from js to php?
Good day!
It is necessary to transfer the received value from the data-id-offers attribute to the php variable in the product card.
In the file /bitrix/templates/test/components/bitrix/catalog.element/main/script.js I set the value of the data-id-offers attribute and write it to idOffers
document.getElementById("out").dataset.idOffers = this.offers[index].ID;
var idOffers = this.offers[index].ID;
$.ajax({
url: "/bitrix/templates/test/components/bitrix/catalog.element/main/template.php",
type: "POST",
data: {idOffers:idOffers}
BX.ajax.post(
url: this.ajaxURL,
type: post,
data: {idOffers:idOffers}
);
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