Есть кнопка
<button type="button" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="instock.add('<?php echo $product['product_id']; ?>');"><?php echo $buttonundersell_title; ?></button>
есть js в котором 2 функции
в одной product_id передаеться
var instock = {
'add': function(product_id) {
$.ajax({
url: 'index.php?route=module/validOrder',
type: 'post',
data: 'product_id=' + product_id,
dataType: 'json',
success: function(json) {
$('.alert, .text-danger').remove();
$('.form-group').removeClass('has-error');
$.magnificPopup.open({
items: {
src: 'index.php?route=module/getForm&product_id='+ product_id
},
type: 'ajax'
});
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
},
'remove': function() {
}
}
но тут product_id не срабатывает (data: 'product_id=' + product_id, )
$(document).on("click touchstart", "#undersell-order-submit", function (product_id) {
$.ajax({
url: 'index.php?route=module//write',
type: 'post',
dataType: 'json',
data: 'product_id=' + product_id,
success: function (data) {
...................
}
}
if (data['success']) {
setTimeout(function() {
$.magnificPopup.close();
}, 5500);
$.magnificPopup.open({
items: {
src: 'index.php?route=module//success'
},
type: 'ajax'
});
}
}
});
});