Answer the question
In order to leave comments, you need to log in
How to pass a value from JS to PHP without reloading the page?
There is a page. It is necessary that when clicking on a certain element, a variable with the value n is passed to php. Next, the PHP script is executed and again, without reloading the page, a block is loaded into html, the id of which corresponds to the value of the passed variable. Need logic or implementation example. I'm not familiar with AJAX and JSON, but if you point me in the right direction, I think I'll figure it out. Thanks to all.
Answer the question
In order to leave comments, you need to log in
$.ajax({
type: 'POST',
url: 'response.php?action=sample2',
data: 'name=Andrew&nickname=Aramis',
success: function(data){
$('.results').html(data);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question