title: Undefined index: Error in ajax POST and/or php script?
body: <p>I'm trying to send an ajax POST to a php file, however the php file sends a notice of "undefined index", and the php file never seems to receive the value i'm trying to send it. I've been searching for the answer to why this isn't working correctly, so hopefully someone can give me some insight. </p>
  
  <p>My javascript function receives a value from the html, and receives the correct value. (it's "1" in this case)</p>
  
  <pre><code>    function deleteMediaFromDatabase(val)
      {
  
    $.ajax({ url: 'deleteMediaFromDatabase.php',
           data: {vals : val},
           type: 'post',
           success: function(output) {
                        alert(output);
                    },
            error: function(request, status, error){
              alert("Error: Could not delete");
            }
    });
  }
  </code></pre>
  
  <p>Here is part of my php file that should receive the post:</p>
  
  <pre><code>    &lt;?php
  
   ini_set("display_errors", "On");
   error_reporting(E_ALL);
  
      $val = $_POST["vals"];
  
      // create connection
      $con = mysqli_connect(&lt;stuff you don't care about&gt;);
  
    error_log($val . ' is the value', 3, "./error.log");
  
  ?&gt;
  </code></pre>
  
  <p>I am, however getting this error message from php: </p>
  
  <blockquote>
    <p>Notice: Undefined index: vals in
    /xxx/xxx/htdocs/AdminPanel/deleteMediaFromDatabase.php on line 9</p>
  </blockquote>
  
  <p>And my javascript always outputs the alert in the error: "Error: Could not delete"</p>
  
  <p>I know this question has been asked and answered many times, however unless I'm skipping over something small, my code, to me, looks correct. (but doesn't it always...)</p>