`Is it possible to work like this with ajax`om <meta name="yandex-verification" content="b48eb87065220426" /> <link rel="apple-touch-icon" sizes="57x57" href="/assets/theme/favicon/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="/assets/theme/favicon/apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="/assets/theme/favicon/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="/assets/theme/favicon/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="/assets/theme/favicon/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="/assets/theme/favicon/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="/assets/theme/favicon/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="/assets/theme/favicon/apple-icon-152x152.png"> <link rel="apple-touch-icon" sizes="180x180" href="/assets/theme/favicon/apple-icon-180x180.png"> <link rel="icon" type="image/png" sizes="192x192" href="/assets/theme/favicon/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="32x32" href="/assets/theme/favicon/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="96x96" href="/assets/theme/favicon/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="16x16" href="/assets/theme/favicon/favicon-16x16.png"> <link rel="manifest" href="/assets/theme/favicon/manifest.json"> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileImage" content="/assets/theme/favicon/ms-icon-144x144.png"> <meta name="theme-color" content="#ffffff"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8700890447935372" crossorigin="anonymous"></script> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-N7006N1W94"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-N7006N1W94'); </script> </head> <style> .name-color-A {background:#FF8C7C} .name-color-B {background:#ff8cc8} .name-color-C {background:#BE90D4} .name-color-D {background:#BE90D4} .name-color-E {background:#1297e0} .name-color-F {background:#27cbc0} .name-color-G {background:#2ecc71} .name-color-H {background:#F5AB35} .name-color-I {background:#f3825b} .name-color-J {background:#be8c6b} .name-color-K {background:#4c5a69} .name-color-L {background:#657576} .name-color-M {background:#707070} .name-color-N {background:#870000} .name-color-O {background:#9a0038} .name-color-P {background:#3e005d} .name-color-Q {background:#003780} .name-color-R {background:#005b50} .name-color-S {background:#005c01} .name-color-T {background:#a84410} .name-color-U {background:#932210} .name-color-V {background:#5e2c0b} .name-color-W {background:#2c3a49} .name-color-X {background:#d35400} .name-color-Y {background:#2c3e50} .name-color-Z {background:#3498db} .pagination { display: inline-block; padding-left: 0; margin: 20px 0; border-radius: 4px; } .pagination > li { display: inline; } .pagination > li > a, .pagination > li > span { position: relative; float: left; padding: 6px 12px; margin-left: -1px; line-height: 1.42857143; color: #337ab7; text-decoration: none; background-color: #ffffff; border: 1px solid #dddddd; } .pagination > li > a:hover, .pagination > li > span:hover, .pagination > li > a:focus, .pagination > li > span:focus { z-index: 2; color: #23527c; background-color: #eeeeee; border-color: #dddddd; } .pagination > li:first-child > a, .pagination > li:first-child > span { margin-left: 0; border-top-left-radius: 4px; border-bottom-left-radius: 4px; } .pagination > li:last-child > a, .pagination > li:last-child > span { border-top-right-radius: 4px; border-bottom-right-radius: 4px; } .pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover, .pagination > .active > a:focus, .pagination > .active > span:focus { z-index: 3; color: #ffffff; cursor: default; background-color: #337ab7; border-color: #337ab7; } .pagination > .disabled > span, .pagination > .disabled > span:hover, .pagination > .disabled > span:focus, .pagination > .disabled > a, .pagination > .disabled > a:hover, .pagination > .disabled > a:focus { color: #777777; cursor: not-allowed; background-color: #ffffff; border-color: #dddddd; } .pagination-lg > li > a, .pagination-lg > li > span { padding: 10px 16px; font-size: 18px; line-height: 1.3333333; } .pagination-lg > li:first-child > a, .pagination-lg > li:first-child > span { border-top-left-radius: 6px; border-bottom-left-radius: 6px; } .pagination-lg > li:last-child > a, .pagination-lg > li:last-child > span { border-top-right-radius: 6px; border-bottom-right-radius: 6px; } .pagination-sm > li > a, .pagination-sm > li > span { padding: 5px 10px; font-size: 12px; line-height: 1.5; } .pagination-sm > li:first-child > a, .pagination-sm > li:first-child > span { border-top-left-radius: 3px; border-bottom-left-radius: 3px; } .pagination-sm > li:last-child > a, .pagination-sm > li:last-child > span { border-top-right-radius: 3px; border-bottom-right-radius: 3px; } .pagination .without-link { position: relative; float: left; padding: 6px 12px; margin-left: -1px; line-height: 1.42857143; color: #337ab7; text-decoration: none; background-color: #ffffff; border: 1px solid #dddddd; border-top-left-radius: 4px; border-bottom-left-radius: 4px; } .pagination .page-item:nth-child(1) img { transform: rotate(180deg); } @media only screen and (max-width : 320px) { .content__item-content { width: 100% !important; padding-right: 0px !important; box-sizing: border-box; } } </style> <body> <div class="wrapper"> <!-- Google Tag Manager (noscript) --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NLLJJ7T" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) --> <header class="header"> <div class="header__body"> <div class="header__row container"> <div class="header__left"> <div class="header__button"> <span class="header__button-line"></span></div><a class="header__logo lg" href="/"> <img src="/assets/theme/img/logo.png" style="width: 150px;" alt="" draggable="false" loading="lazy"></a> <a class="header__logo sm" href="index.html"> <img src="/assets/theme/img/logo.png" style="width: 150px;" alt="" draggable="false" loading="lazy"> </a> </div> <ul class="header__list lg"> <li class="header__li drop-container"> <button class="drop header__link" type="button"> <div class="icon icon-category"> </div><span>Categories</span> </button> <div class="drop__content"> <div class="drop__col"> <!--<a class="drop__link strong border">All Project Questions</a>--> <a class="drop__link" href="/category/javascript">JavaScript</a><a class="drop__link" href="/category/php">PHP</a><a class="drop__link" href="/category/html">HTML</a><a class="drop__link" href="/category/css">Css</a><a class="drop__link" href="/category/python">Python</a><a class="drop__link" href="/category/wordpress">WordPress</a><a class="drop__link" href="/category/web-development">Web development</a><a class="drop__link" href="/category/linux">Linux</a><a class="drop__link" href="/category/mysql">MySQL</a><a class="drop__link" href="/category/android">Android</a> </div> <div class="drop__col"> <a class="drop__link" href="/category/windows">Windows</a><a class="drop__link" href="/category/java">Java</a><a class="drop__link" href="/category/c">C++ / C#</a><a class="drop__link" href="/category/layout">Layout</a><a class="drop__link" href="/category/react">React</a><a class="drop__link" href="/category/ubuntu">Ubuntu</a><a class="drop__link" href="/category/yii">Yii</a><a class="drop__link" href="/category/django">Django</a><a class="drop__link" href="/category/programming">Programming</a><a class="drop__link" href="/category/1c-bitrix">1C-Bitrix</a> </div> <div class="drop__col"> <a class="drop__link" href="/category/laravel">Laravel</a><a class="drop__link" href="/category/system-administration">System administration</a><a class="drop__link" href="/category/telegram">Telegram</a><a class="drop__link" href="/category/json">JSON</a><a class="drop__link" href="/category/debian">Debian</a><a class="drop__link" href="/category/postgresql">PostgreSQL</a><a class="drop__link" href="/category/ios">IOS</a><a class="drop__link" href="/category/google">Google</a><a class="drop__link" href="/category/htaccess">Htaccess</a><a class="drop__link" href="/category/windows-server">Windows Server</a> </div> <div class="drop__col"> <a class="drop__link" href="/category/git">Git</a><a class="drop__link" href="/category/macos">MacOS</a><a class="drop__link" href="/category/google-chrome">Google Chrome</a><a class="drop__link" href="/category/cms">CMS</a><a class="drop__link" href="/category/woocommerce">WooСommerce</a><a class="drop__link" href="/category/bootstrap">Bootstrap</a><a class="drop__link" href="/category/nginx">Nginx</a><a class="drop__link" href="/category/sql">SQL</a><a class="drop__link" href="/category/unity">Unity</a><a class="drop__link" href="/category/api">API</a> </div> </div> </li> <li class="header__li"> <a class="header__link" href="#!"> <div class="icon icon-add"> </div><span>Ask </span></a></li> <li class="header__li"> <a class="header__link" href="leaders.html"> <div class="icon icon-stats"> </div><span>Leaders </span></a></li> </ul> <ul class="header__list sm"> <li class="header__list-item"> <a href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M10.91 12.806A6.964 6.964 0 017 14c-3.863 0-7-3.137-7-7s3.137-7 7-7 7 3.137 7 7a6.97 6.97 0 01-1.18 3.889l2.114 2.113a1.354 1.354 0 01-1.914 1.914l-2.11-2.11zM7 2.477A4.524 4.524 0 0111.523 7 4.524 4.524 0 017 11.523 4.524 4.524 0 012.477 7 4.524 4.524 0 017 2.477z"></path></svg></a></li> <li class="header__list-item"> <a href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M8.4 1a.6.6 0 01.6.6V7h5.4a.6.6 0 01.6.6v.8a.6.6 0 01-.6.6H9v5.4a.6.6 0 01-.6.6h-.8a.6.6 0 01-.6-.6V9H1.6a.6.6 0 01-.6-.6v-.8a.6.6 0 01.6-.6H7V1.6a.6.6 0 01.6-.6h.8z"></path></svg></a></li> </ul> <div class="header__right"> <form class="header__search search-bar" action="search.html" method="post"> <input name="username" type="text" style="display:none"> <input name="search-question" required minlength="3" class="search-bar__input" type="text" required autocomplete="off" placeholder="Search by questions"> <button class="search-bar__btn" type="submit"> <div class="icon icon-search"> </div> </button> </form> <div class="header__seperator"> <div></div> </div> </div> </div> </div> <div class="header__menu"> <div class="header__menu-body container"> <p class="header__menu-title">Categories </p> <a class="header__menu-link" href="/category/javascript">JavaScript</a><a class="header__menu-link" href="/category/php">PHP</a><a class="header__menu-link" href="/category/html">HTML</a><a class="header__menu-link" href="/category/css">Css</a><a class="header__menu-link" href="/category/python">Python</a><a class="header__menu-link" href="/category/wordpress">WordPress</a><a class="header__menu-link" href="/category/web-development">Web development</a><a class="header__menu-link" href="/category/linux">Linux</a><a class="header__menu-link" href="/category/mysql">MySQL</a><a class="header__menu-link" href="/category/android">Android</a><a class="header__menu-link" href="/category/windows">Windows</a><a class="header__menu-link" href="/category/java">Java</a><a class="header__menu-link" href="/category/c">C++ / C#</a><a class="header__menu-link" href="/category/layout">Layout</a><a class="header__menu-link" href="/category/react">React</a><a class="header__menu-link" href="/category/ubuntu">Ubuntu</a><a class="header__menu-link" href="/category/yii">Yii</a><a class="header__menu-link" href="/category/django">Django</a><a class="header__menu-link" href="/category/programming">Programming</a><a class="header__menu-link" href="/category/1c-bitrix">1C-Bitrix</a><a class="header__menu-link" href="/category/laravel">Laravel</a><a class="header__menu-link" href="/category/system-administration">System administration</a><a class="header__menu-link" href="/category/telegram">Telegram</a><a class="header__menu-link" href="/category/json">JSON</a><a class="header__menu-link" href="/category/debian">Debian</a><a class="header__menu-link" href="/category/postgresql">PostgreSQL</a><a class="header__menu-link" href="/category/ios">IOS</a><a class="header__menu-link" href="/category/google">Google</a><a class="header__menu-link" href="/category/htaccess">Htaccess</a><a class="header__menu-link" href="/category/windows-server">Windows Server</a><a class="header__menu-link" href="/category/git">Git</a><a class="header__menu-link" href="/category/macos">MacOS</a><a class="header__menu-link" href="/category/google-chrome">Google Chrome</a><a class="header__menu-link" href="/category/cms">CMS</a><a class="header__menu-link" href="/category/woocommerce">WooСommerce</a><a class="header__menu-link" href="/category/bootstrap">Bootstrap</a><a class="header__menu-link" href="/category/nginx">Nginx</a><a class="header__menu-link" href="/category/sql">SQL</a><a class="header__menu-link" href="/category/unity">Unity</a><a class="header__menu-link" href="/category/api">API</a> </div> </div> </header> <main class="main"> <div class="main__body container"> <aside class="sidebar"> <a class="sidebar__title" href="#!">Programming </a> <div class="sidebar__list"> <a class="sidebar__item " href="/category/javascript">JavaScript </a><a class="sidebar__item " href="/category/php">PHP </a><a class="sidebar__item " href="/category/html">HTML </a><a class="sidebar__item " href="/category/css">Css </a><a class="sidebar__item " href="/category/python">Python </a><a class="sidebar__item " href="/category/wordpress">WordPress </a><a class="sidebar__item " href="/category/web-development">Web development </a><a class="sidebar__item " href="/category/linux">Linux </a><a class="sidebar__item " href="/category/mysql">MySQL </a><a class="sidebar__item " href="/category/android">Android </a><a class="sidebar__item " href="/category/windows">Windows </a><a class="sidebar__item " href="/category/java">Java </a><a class="sidebar__item " href="/category/c">C++ / C# </a><a class="sidebar__item " href="/category/layout">Layout </a><a class="sidebar__item " href="/category/react">React </a><a class="sidebar__item " href="/category/ubuntu">Ubuntu </a><a class="sidebar__item " href="/category/yii">Yii </a><a class="sidebar__item " href="/category/django">Django </a><a class="sidebar__item " href="/category/programming">Programming </a><a class="sidebar__item " href="/category/1c-bitrix">1C-Bitrix </a><a class="sidebar__item " href="/category/laravel">Laravel </a><a class="sidebar__item " href="/category/system-administration">System administration </a><a class="sidebar__item " href="/category/telegram">Telegram </a><a class="sidebar__item " href="/category/json">JSON </a><a class="sidebar__item " href="/category/debian">Debian </a><a class="sidebar__item " href="/category/postgresql">PostgreSQL </a><a class="sidebar__item " href="/category/ios">IOS </a><a class="sidebar__item " href="/category/google">Google </a><a class="sidebar__item " href="/category/htaccess">Htaccess </a><a class="sidebar__item " href="/category/windows-server">Windows Server </a> </div> <div class="sidebar__list"> </div> </aside> <div class="mid"> <div class="content similar"> <div class="content__header bb-none"> <div class="content__item-wrap"> <div class="content__item p0 b-none"> <div class="content__item-btn dropdown"> <button class="dropdown__btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M8 11.365a1.817 1.817 0 010 3.632 1.817 1.817 0 010-3.632zm0-5.191a1.826 1.826 0 010 3.65 1.826 1.826 0 010-3.65zm0-5.171a1.81 1.81 0 11-.001 3.617A1.81 1.81 0 018 1.003z"></path></svg></button> <div class="dropdown__content"> <a class="dropdown__item" href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M7.919 12.563c-.856.567-2.304 1.504-3.757 2.444-.226.19-.542.237-.858.111-.46-.184-.552-.645-.368-1.105l1.197-4.512L.929 6.567c-.174-.141-.295-.353-.295-.565 0-.46.368-.737.736-.737h4.173l1.683-3.928C7.38.987 7.658.793 8 .793h.008c.338.005.614.196.766.544l1.684 3.928h4.172c.368 0 .737.277.737.737 0 .212-.122.424-.296.565l-3.203 2.934 1.197 4.512c.184.46.092.921-.369 1.105-.315.126-.631.079-.858-.111A503.075 503.075 0 018 12.509l-.081.054z"></path></svg><span>Make a leader</span></a><a class="dropdown__item" href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0c4.415 0 8 3.585 8 8s-3.585 8-8 8-8-3.585-8-8 3.585-8 8-8zm.999 11a1 1 0 10-2 0 1 1 0 002 0zm0-6a1 1 0 00-2 0v3a1 1 0 002 0V5z"></path></svg><span>Report </span></a></div> </div> <div class="content__item-img dn name-color-A"> <span>A</span></div> <div class="content__item-content"> <div class="content__item-top sm"> <div class="content__item-top-info"> <div class="content__item-img name-color-A"> <span>A</span></div> <div class="content__item-top-div"> <a class="content__item-top-name" href="#!">alexei_2002</a><span class="content__item-top-p">2021-10-29 01:42:36</span></div> </div> </div> <a class="content__item-top-category" href="/category/ajax">AJAX </a> <div class="content__item-row dn"> <a href="#!"><b>alexei_2002</b>,</a> 2021-10-29 01:42:36</div> <p class="content__item-title large">Is it possible to work like this with ajax`om?</p> <p class="content__item-detail sm"> Variables with the correct values, but ajax seems to work only at the moment the value is passed to the button and that's it. <br> Maybe it's just impossible to pass values ​​to data like that?<br> <pre><code class="javascript hljs">tempvar_name_group = $(<span class="hljs-keyword">this</span>).attr(<span class="hljs-string">"value"</span>); j = <span class="hljs-number">1</span>; tempvar_surname = $(<span class="hljs-string">`#ipt_surname<span class="hljs-subst">${j}</span>`</span>).val(); tempvar_name = $(<span class="hljs-string">`#ipt_name<span class="hljs-subst">${j}</span>`</span>).val(); tempvar_patronymic = $(<span class="hljs-string">`#ipt_patronymic<span class="hljs-subst">${j}</span>`</span>).val(); number_student = <span class="hljs-string">`ipt_insert_number_student<span class="hljs-subst">${j}</span>`</span>; surname = <span class="hljs-string">`ipt_insert_surname<span class="hljs-subst">${j}</span>`</span>; name = <span class="hljs-string">`ipt_insert_name<span class="hljs-subst">${j}</span>`</span>; patronymic = <span class="hljs-string">`ipt_insert_patronymic<span class="hljs-subst">${j}</span>`</span>; $.post(<span class="hljs-string">"ajax_quest.php"</span>, {<span class="hljs-attr">n_btn_save_students</span>: <span class="hljs-string">"n_btn_save_students"</span>, <span class="hljs-attr">ipt_n_show_table</span>: tempvar_name_group, <span class="hljs-attr">number_student</span>: j, <span class="hljs-attr">surname</span>: tempvar_surname, <span class="hljs-attr">name</span>: tempvar_name, <span class="hljs-attr">patronymic</span>: tempvar_patronymic}) .done(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"> data </span>) </span>{ });</code></pre><br> <pre><code class="php hljs"><span class="hljs-keyword">if</span> ( <span class="hljs-keyword">isset</span> ($_POST[<span class="hljs-string">'n_btn_save_students'</span>])){ <span class="hljs-keyword">for</span> ($j = <span class="hljs-number">1</span>; $j <=<span class="hljs-number">25</span>; $j++){ <span class="hljs-keyword">if</span>($_POST[<span class="hljs-string">'ipt_insert_surname'</span>.$j.<span class="hljs-string">''</span>] == <span class="hljs-keyword">true</span>){ <span class="hljs-keyword">if</span>($_POST[<span class="hljs-string">'ipt_insert_name'</span>.$j.<span class="hljs-string">''</span>] == <span class="hljs-keyword">true</span>){ <span class="hljs-keyword">if</span>($_POST[<span class="hljs-string">'ipt_insert_patronymic'</span>.$j.<span class="hljs-string">''</span>] == <span class="hljs-keyword">true</span>){ $num_stud = $_POST[<span class="hljs-string">'ipt_insert_number_student'</span>.$j.<span class="hljs-string">''</span>]; $surname = $_POST[<span class="hljs-string">'ipt_insert_surname'</span>.$j.<span class="hljs-string">''</span>]; $name = $_POST[<span class="hljs-string">'ipt_insert_name'</span>.$j.<span class="hljs-string">''</span>]; $patronymic = $_POST[<span class="hljs-string">'ipt_insert_patronymic'</span>.$j.<span class="hljs-string">''</span>]; $query_insert_fio = <span class="hljs-string">"INSERT INTO `"</span>.$_SESSION[<span class="hljs-string">'temp_name_group'</span>].<span class="hljs-string">"` (`id`, `surname`, `name`, `patronymic`) VALUES (:num_stud, :surname, :name, :patronymic)"</span>; $query_insert_fio_params = [ <span class="hljs-string">':num_stud'</span> => $num_stud, <span class="hljs-string">':surname'</span> => $surname, <span class="hljs-string">':name'</span> => $name, <span class="hljs-string">':patronymic'</span> => $patronymic]; $stmt = $pdo->prepare($query_insert_fio); $stmt->execute($query_insert_fio_params); } } } } $mess = <span class="hljs-string">"Студенты успешно добавлены в БД!"</span>; <span class="hljs-keyword">echo</span> <span class="hljs-string">'<div id = "message">'</span>.$mess.<span class="hljs-string">'</div>'</span>; }</code></pre> </p> <div class="content__action"> <div class="content__action-left"> <a href="https://askmeplz.com/q/is-it-possible-to-work-like-this-with-ajax-om#answer" class="content__form-button lg" type="submit"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="DY2o8"> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path></svg><span>Reply </span> </a> <button class="content__action-btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M7.125 14.998c-.003 0-1.516.026-2.28-.635-.825-.714-.845-1.99-.845-1.99V8.961s-.003-1.885.754-2.756c.757-.872 2.431-1.886 2.96-2.614.529-.729.834-1.722 1.672-1.722.837 0 1.239.521 1.239 1.311 0 .377-.349 1.144-.349 2.193 0 .408.34.625.893.625H13c1.263 0 2 .771 2 2 0 .653-.359 1.223-.889 1.524a1.751 1.751 0 01-.876 1.75 1.751 1.751 0 01-.875 1.75 1.75 1.75 0 01-1.735 1.976h-3.5zM3 7.56c0-.724-.276-1.312-1-1.312S1 6.836 1 7.56v6.125c0 .725.276 1.313 1 1.313s1-.588 1-1.313V7.56z"></path></svg></button> </div> <div class="content__action-right"> <button class="content__action-btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="QKbwC"><path fill-rule="evenodd" d="M13 2.779C13 1.796 12.204 1 11.221 1H4.779C3.796 1 3 1.796 3 2.779v11.192a1 1 0 001.746.667l2.793-3.123a.618.618 0 01.922 0l2.793 3.123A1.001 1.001 0 0013 13.971V2.779zm-2 .82a.6.6 0 00-.601-.601H5.607A.608.608 0 005 3.606v7.272a.232.232 0 00.402.158l2.146-2.292a.619.619 0 01.904 0l2.151 2.298a.23.23 0 10.397-.157V3.599z"></path></svg></button> <button class="content__action-btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M8.88 3.37a.3.3 0 00.122-.252A3.001 3.001 0 0115 3a3.001 3.001 0 01-4.951 2.278.292.292 0 00-.366-.017c-.564.407-2.189 1.588-2.649 1.922a.233.233 0 00-.09.234 3.098 3.098 0 01-.001 1.166.234.234 0 00.091.234l2.648 1.924a.295.295 0 00.368-.018A2.978 2.978 0 0112 10a3.001 3.001 0 010 6 3.001 3.001 0 01-2.998-3.118.295.295 0 00-.122-.251l-2.896-2.105a.315.315 0 00-.358-.007A2.968 2.968 0 014 11a3.001 3.001 0 010-6c.599 0 1.158.176 1.627.48.108.072.25.069.355-.007.58-.419 2.392-1.736 2.898-2.103z"></path></svg></button> </div> <a href="https://askmeplz.com/q/is-it-possible-to-work-like-this-with-ajax-om#answer" class="content__form-button sm" type="submit"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="DY2o8"><path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path></svg><span>Answer the question</span></a> </div> </div> </div> <a name="answer"></a> </div> </div> </div> <div class="content"> <div class="content__header bb-none"> <p class="content__title dn">Answer the question</p> <div class="content__form"> <p>In order to leave comments, you need to <a href=вход.html>log in</a></p> </div> </div> </div> <div class="content"> <div class="content__header bb-none answer-wrapper"> <a class="content__title mb0 answer-title" href="#!">1 answer(s) </a> <div class="answer"> <div class="content__item-btn dropdown"> <button class="dropdown__btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M8 11.365a1.817 1.817 0 010 3.632 1.817 1.817 0 010-3.632zm0-5.191a1.826 1.826 0 010 3.65 1.826 1.826 0 010-3.65zm0-5.171a1.81 1.81 0 11-.001 3.617A1.81 1.81 0 018 1.003z"></path></svg></button> <div class="dropdown__content"> <a class="dropdown__item" href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0c4.415 0 8 3.585 8 8s-3.585 8-8 8-8-3.585-8-8 3.585-8 8-8zm.999 11a1 1 0 10-2 0 1 1 0 002 0zm0-6a1 1 0 00-2 0v3a1 1 0 002 0V5z"></path></svg><span>Report </span></a></div> </div> <div class="answer__header"> <div class="content__item-img large name-color-S"><span>S</span></div><span class="answer__name"><a href="#!">Sergey _</a>, 2021-10-29 <br/> @SiteCenter</span> </div> <p class="answer__detail">First, you have incorrect PHP code. Even if empty values ​​come from the form, your code will display a message about the successful addition of students to the database, but in fact they are not added. It is better to get rid of nesting (if->if->if). Checking for the existence of a non-empty variable is best done using isset(). Regarding Ajax, as far as I understand, you send it immediately after the page is loaded, so the data from the input is not transmitted. Try to replace<br> <pre><code class="javascript hljs">$.post(<span class="hljs-string">"ajax_quest.php"</span>, {<span class="hljs-attr">n_btn_save_students</span>: <span class="hljs-string">"n_btn_save_students"</span>, <span class="hljs-attr">ipt_n_show_table</span>: tempvar_name_group, <span class="hljs-attr">number_student</span>: j, <span class="hljs-attr">surname</span>: tempvar_surname, <span class="hljs-attr">name</span>: tempvar_name, <span class="hljs-attr">patronymic</span>: tempvar_patronymic}) .done(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"> data </span>) </span>{ });</code></pre><br> on the<br> <pre><code class="javascript hljs">$( <span class="hljs-string">"#target"</span> ).click(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ $.post(<span class="hljs-string">"ajax_quest.php"</span>, {<span class="hljs-attr">n_btn_save_students</span>: <span class="hljs-string">"n_btn_save_students"</span>, <span class="hljs-attr">ipt_n_show_table</span>: tempvar_name_group, <span class="hljs-attr">number_student</span>: j, <span class="hljs-attr">surname</span>: tempvar_surname, <span class="hljs-attr">name</span>: tempvar_name, <span class="hljs-attr">patronymic</span>: tempvar_patronymic}) .done(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"> data </span>) </span>{ }); });</code></pre><br> where target is the id of the element on which the click is made (as an example, you can replace id with a css property, or even bind to another event).</p> <div class="answer__action"> <button class="answer__btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="qWxAZ YJAqn"><path fill-rule="evenodd" d="M7.125 14.998c-.003 0-1.516.026-2.28-.635-.825-.714-.845-1.99-.845-1.99V8.961s-.003-1.885.754-2.756c.757-.872 2.431-1.886 2.96-2.614.529-.729.834-1.722 1.672-1.722.837 0 1.239.521 1.239 1.311 0 .377-.349 1.144-.349 2.193 0 .408.34.625.893.625H13c1.263 0 2 .771 2 2 0 .653-.359 1.223-.889 1.524a1.751 1.751 0 01-.876 1.75 1.751 1.751 0 01-.875 1.75 1.75 1.75 0 01-1.735 1.976h-3.5zM3 7.56c0-.724-.276-1.312-1-1.312S1 6.836 1 7.56v6.125c0 .725.276 1.313 1 1.313s1-.588 1-1.313V7.56z"></path></svg>Like</button> <button class="answer__btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="qPhqc"><path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path></svg><span>0 </span>comments</button> </div> </div> </div> </div> <div class="content similar"> <div class="content__header bb-none"> <span class="content__title mb0 w-svg"> Similar questions </span> <div class="content__item-wrap"> <div class="content__item"> <div class="content__item-img name-color-B"> <span>B</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/displaying-posts-in-a-field-using-ajax">bugs__2703</a><span>2021-04-13 09:04:11</span></div> <a class="content__item-title similar" href="/q/displaying-posts-in-a-field-using-ajax">Displaying posts in a field using Ajax?</a> <a class="content__item-button" href="/q/displaying-posts-in-a-field-using-ajax"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">1</span><span class="dn">Reply</span> </a> </div> </div><div class="content__item"> <div class="content__item-img name-color-S"> <span>S</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/ajax-request-to-load-a-new-page">Sanzhar Bazarbek</a><span>2021-04-15 00:44:33</span></div> <a class="content__item-title similar" href="/q/ajax-request-to-load-a-new-page">AJAX request to load a new page?</a> <a class="content__item-button" href="/q/ajax-request-to-load-a-new-page"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">1</span><span class="dn">Reply</span> </a> </div> </div><div class="content__item"> <div class="content__item-img name-color-L"> <span>L</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/how-to-ajax-om-get-information-from-the-server">LyciferZla</a><span>2019-10-22 18:17:46</span></div> <a class="content__item-title similar" href="/q/how-to-ajax-om-get-information-from-the-server">How to AJAX'om get information from the server?</a> <a class="content__item-button" href="/q/how-to-ajax-om-get-information-from-the-server"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">1</span><span class="dn">Reply</span> </a> </div> </div><div class="content__item"> <div class="content__item-img name-color-I"> <span>I</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/how-to-create-a-reverse-form-in-wordpress-with-ajax">Ivan</a><span>2021-04-24 20:40:57</span></div> <a class="content__item-title similar" href="/q/how-to-create-a-reverse-form-in-wordpress-with-ajax">How to create a reverse form in WordPress with ajax?</a> <a class="content__item-button" href="/q/how-to-create-a-reverse-form-in-wordpress-with-ajax"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">1</span><span class="dn">Reply</span> </a> </div> </div><div class="content__item"> <div class="content__item-img name-color-S"> <span>S</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/like-system-how-to-pass-specific-post-id-to-js-file">Saken Satenov</a><span>2021-05-06 03:43:27</span></div> <a class="content__item-title similar" href="/q/like-system-how-to-pass-specific-post-id-to-js-file">Like system. How to pass specific post_id to js file?</a> <a class="content__item-button" href="/q/like-system-how-to-pass-specific-post-id-to-js-file"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">1</span><span class="dn">Reply</span> </a> </div> </div> </div> </div> </div> <div class="content find"> <p class="find__p">Didn't find what you were looking for?</p><a class="find__btn" href="#!">Ask your question</a> </div> <div class="find sm"> <p class="find__title">Ask a Question </p> <form class="find__form" action="#!"> <input class="find__input" type="text" placeholder="Ask your question here"> <button class="find__btn" type="submit"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16" class="nBqR1"><path fill-rule="evenodd" d="M12.696 7.256L9.657 4.217a1 1 0 00-1.415 1.414l1.344 1.344H3.949a1.001 1.001 0 000 2h5.637l-1.344 1.343a1.002 1.002 0 000 1.415c.391.39 1.024.39 1.415 0l3.039-3.04A.993.993 0 0013 7.975a.997.997 0 00-.293-.708l-.011-.011z"></path></svg></button> </form> <p class="find__span">731 491 924 answers to any question</p> </div> </div> <aside class="banners"> <p>banners </p> </aside> </div> </main> </div> <script src="/assets/theme/js/highlight/highlight.min.js"></script> <script src="/assets/theme/js/app.min.js?_v=20220404145216"> </script> <script>hljs.highlightAll();</script> </body> </html>