I want to get the data from the form without updating the page.
The form:
<form id="myform" action="#" method="POST" enctype="multipart/form-data"> Персонаж <select id="pers" name="personaj"> <option value="бэтмен">Бэтмен</option> <option value="супер-мен">Супер мен</option> </select> <span id="contentST">Персонаж:</span> <input id="link" type="button" name="calc" value="Выбрать" /> </form> ajax:
$(document).ready(function(){ $("#link").click(function(){ $.ajax({ url: "1.php", type: "GET", dataType: "html", success: function(response){ $("#contentST").html(response); } }); }); }); Code 1.php:
echo '<span id="contentST">Выбранный персонаж: '.$_POST['personaj'].'</span>'; It turns out when you press the button without refreshing the page, the word Персонаж is replaced with the Выбранный персонаж but it does not display the selected character, that is, the $_POST['personaj'] code does not work.
I would be grateful for the help.