title: How can I check if a button is pressed without using a form and without refreshing the page?
body: <p>The code I have is a side bar that uses javascript to appear and disappear. When a button (create group) is pressed it resets the page. I want to be able to press the button, have php do something like:  and It has to not refresh the page. Here is the code:</p>
  <pre><code>   &lt;header class=&quot;header&quot;&gt;
       &lt;div class=&quot;btn-toggle-nav&quot; onclick=&quot;toggleNav()&quot;&gt;&lt;/div&gt;
       &lt;h1 class=&quot;logobrand&quot;&gt;DEVIE&lt;/h1&gt;
     &lt;/header&gt;
     &lt;aside class=&quot;nav-sidebar&quot;&gt;
       &lt;ul&gt;
         &lt;li&gt; &lt;p&gt;Friends&lt;/p&gt; &lt;/li&gt;
         &lt;li&gt;
           &lt;button name=&quot;creategroup&quot;&gt;Create a group&lt;/button&gt;&lt;/li&gt;
         &lt;?php
       foreach (getGroups($_SESSION['user-id']) as $group) {
             echo &quot;&lt;li&gt; &lt;p&gt; &quot;. $group .&quot; &lt;/p&gt; &lt;/li&gt;&quot;;
         }
         ?&gt;
       &lt;/ul&gt;
     &lt;/aside&gt;
     &lt;?php if (isset(['creategroup'])) {
       echo &quot;please work&quot;;
     } ?&gt;
   &lt;/body&gt;
  </code></pre>
  <p>Please help</p>