$ .post返回值0

I'm want to get a variable from Javascript to PHP via the POST function. I have tried to do something like this:

The problem line:

$.post(window.location, {idafevent: event.id});

Javascript:

eventRender: function(event, element) {
  element.bind('dblclick', function() {
    $('#ModalEdit #id').val(event.id);
    $('#ModalEdit #title').val(event.title);
    $('#ModalEdit #color').val(event.color);
    $('#ModalEdit #medlemmerid').val(event.id);
    $('#ModalEdit #sletid').val(event.id);
    $.post(window.location, {idafevent: event.id});
    $('#ModalEdit').modal('show');
  });
},

My PHP:

$idafeventet = $_POST['idafevent'];

But the "idafeventet" is "0" when it shouldn't. Why is that?

You should check the browser developer tool and make sure that form data when sending ajax request have contained "idafevent" input. Because I don't see any problem with PHP source code.

Developer tools