JQuery callback functions fired before event

JQuery callback functions fired before event

I don't know if I am doing some silly mistake here but facing this problem of firing callback functions on page init before actual event happens.
Here is the code

  1.     $(document).on("pageinit",function(){
  2.     $("#discInvitePopUp").popup({
  3.             transition: "slidedown",
  4.             history: false,
  5.             afterclose: function( event, ui ) {
  6.                 
  7.                 activeDiscInviteCloseHandler();
  8.             },
  9.             afteropen: function( event, ui ) {
  10.                 openDiscFrmInvite();
  11.             }
  12.         });
  13.     
  14.     }

here are the callback functions:

  1.     function activeDiscInviteCloseHandler(){
  2.         //some code
  3.         //curDiscInv set
  4.         alert("evt");
  5.         $.post("/ajaxReq/user_action.php", {
  6.             unsetInvite:JSON.stringify(curDiscInv)
  7.         }, function(data){
  8.                 
  9.                 
  10.         });
  11.     
  12.     }
  13.     function openDiscFrmInvite(){
  14.        //some code
  15.     }

here problem is that 

  1. activeDiscInviteCloseHandler()

function is called as soon as pageinit event is triggered as a result it sends post data to server which is not desirable.

Any possible solutions to avoid this.