Index undefined in php when obtaining the past value of AJAX


I'm trying to get the value that I passed in AJAX to PHP. It shows an alert that says, "Success!" however it when I try to display the value in PHP, it says undefined index. Also I am passing it in the same page.

Whenever I click a button, it opens a modal and I also passing values from that button to the modal. This is evident in my JS code.

          $('#editModal').on('', function (e) {

            var id = $(e.relatedTarget).data('id'); //im trying to pass this value to php, e.g. 5
            var time = $(e.relatedTarget).data('time');
            var name = $(e.relatedTarget).data('name');
            var stat = $(e.relatedTarget).data('stat');
            var desc = $(e.relatedTarget).data('desc');


           //AJAX CODE HERE
           $(function() {
                    type: "POST",
                    url: 'tasks.php?id='<?php $id = isset($_GET['id']) ? $_GET['id'] : ""; echo $id; ?>,
                    data: { "userID" : id },
                    success: function(data)
                        alert("success!"); //this display

           }); // line 1131



   $uid = $_POST['userID'];
   echo $uid." is the value"; 


It keeps getting an error that says, undefined index: userID. I am confused. Please help me how to fix this. Your help will be much appreciated! Thank you!

Echo the number in the javascript string.

Currently you will get:


The 1 should be concatenated or inside the quote. Try:

url: 'tasks.php?id=<?php $id = isset($_GET['id']) ? $_GET['id'] : ""; echo $id; ?>',

or take that parameter out since it doesn't appear to be being used.