Undefined index: Error in ajax POST and/or php script?

前端 未结 4 1224
清歌不尽
清歌不尽 2021-01-13 22:12

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

4条回答
  •  花落未央
    2021-01-13 22:31

    There is error in syntax of jquery.. You missed out syntax of data. This should be like this-

    function deleteMediaFromDatabase(val)
    {
    $.ajax({ url: 'deleteMediaFromDatabase.php',
         data: {'vals' : val},
         type: 'post',
         dataType:'json',
         success: function(output) {
                      alert(output);
                  },
          error: function(request, status, error){
            alert("Error: Could not delete");
          }
    });
    }
    

提交回复
热议问题