Answer the question
In order to leave comments, you need to log in
How to intercept html code in php?
There is a button, by clicking on which you need to intercept the block with all the content in which this button lies and insert another part of the document:
<?
for ($i=0; $i < count($stock_data[$i]); $i++) {
echo '<div class="main__categoties-wrapper__categorie-item hidden">
<img class="item-img" width="100px" src="img/'.$stock_data[$i][1].'">
<h1 class="main__categoties-wrapper__categorie-item__tittle">'.$stock_data[$i][2].'</h1>
<h2>Артикул: '.$stock_data[$i][0].'</h2>
<h2>Количество: '.$stock_data[$i][3].' шт.</h2>
<form action="#" method="POST"><button class="add-item">Добавить</button></form>
</div>';
}
?>
<form action="#" method="POST"><button class="add-item">Добавить</button></form>
Answer the question
In order to leave comments, you need to log in
here jquery saves
for the button you write a click event handler, you take data from the parent block .parent()
$('.add-item').click(function() {
var content = $(this).parent().html();
$.ajax({
url: 'load.php',
data: {"setting": value_setting},
dataType: "html",
success: function(date) {
// // // функция того, что выходит при успешном завершении скрипта
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question