Answer the question
In order to leave comments, you need to log in
How to pass value to php variable with such request?
Greetings, please tell me how to pass a value from javascript to a php variable with such an asynchronous request.
html:
<td id="varvalue">TestValue</td>
<script>
var sendvar = document.getElementById("varvalue").innerHTML;
async function upIncome(){
let response = await fetch('test.php',{
method: 'POST'
});
document.querySelector('.from-server').innerHTML = await response.text();
}
document.querySelectorAll("input[type='checkbox']").forEach(item=>{
item.addEventListener('click', upIncome)
});
</script>
<?
$hex = ????; //значение innerhtml <td id="varvalue">
echo $hex;
?>
Answer the question
In order to leave comments, you need to log in
There are several solutions here, but read more on stackoverflow
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question