title: I have a problem while fetching date in "class in C:\xampp\htdocs\ERP\std.php on line 4" from ajax code
body: <p>I am new in ajax. i have a problem. i'm selecting value from select tag and sending it into ajax code that give me record at realtime but it display nothing in next select tag. if i tried to open second php file. it diplay error like, "Notice: Undefined index: class in C:\xampp\htdocs\ERP\std.php on line 4". i don't know what to do. help me.
  Here is my code of ajax</p>
  
  <pre><code>&lt;script&gt;
          function myfunction(datavalue) {
              $.ajax({
                  type: 'POST',
                  url: 'std.php',
                  data: { class : datavalue},
  
                  success: function(response){
                      $('#stdName').html(response);
                  }
              });
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>option from where i am getting value</p>
  
  <pre><code> &lt;select name="std-class" onchange="myfunction(this.value)" id="stdClass"&gt;
                                          &lt;?php if(isset($_GET['fee_id'])){?&gt;
                                          &lt;option value="&lt;?php echo $row['std_class']; ?&gt;"&gt;&lt;?php echo $row['std_class'];?&gt;&lt;/option&gt;
                                          &lt;?php }else {?&gt;
                                          &lt;option&gt;Select Class&lt;/option&gt;
                                          &lt;?php }
                                          $std=mysqli_query($con, "SELECT class_name FROM classes");
                                          while($row1=mysqli_fetch_array($std)){
                                          ?&gt;
                                          &lt;option value="&lt;?php echo $row1['class_name'];?&gt;"&gt;&lt;?php echo $row1['class_name'];?&gt;&lt;/option&gt;
                                          &lt;?php }?&gt;
                                      &lt;/select&gt;
  </code></pre>
  
  <p>And this is the php file code</p>
  
  <pre><code>&lt;?php
  $con=mysqli_connect("localhost","root","","sms_db");
  
  $class=$_POST['class'];
  $result=mysqli_query($con, "SELECT * FROM students WHERE class='$class' ORDER BY id ASC");
  while($rows=mysqli_fetch_assoc($result)){ ?&gt;
      &lt;option value="&lt;?php echo $rows['username'];?&gt;"&gt;&lt;?php echo ucwords($rows['name']);?&gt;&lt;/option&gt;
  &lt;?php }
  ?&gt;
  </code></pre>
  
  <p>I also tried this code but it also not working</p>
  
  <pre><code>&lt;script&gt;
          function myfun() {
              var select = document.getElementById('stdClass').value;
              console.log(select);
              $.post("std.php", {
                     class: select
                     },
                     function(response) {
                      $('#stdName').html(response);
              });
          }
      &lt;/script&gt;
  </code></pre>