Answer the question
In order to leave comments, you need to log in
How to pass arResult in ajax.php of a component?
I need to pass the element ID from the same component to the ajax.php script. The arResult array is empty. The option with sessions is not suitable, because if the user opens 2 tabs with different elements, then the ID of the last opened tab will be written to ajax.php.
What other options are there?
Answer the question
In order to leave comments, you need to log in
You can pass the element ID in AJAX:
$(document).ready(function() {
$('#one_click_buy').submit(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: 'component_folder/ajax.php',
dataType: "json",
data: {'id': <?= $arResult['PRODUCT_ID'] ?>},
success: function(response)
{
$('#OneBuyClickRX').modal('hide');
$('#ordersuccess').modal('show');
}
});
});
});
json_decode($id);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question