title: Sending data from php to javascript not working
body: <p>I am trying to send a variable "userID" from php to javascript. But when i print the "data" it is showing the entire javascript document.</p>
  
  <p>Below is the code</p>
  
  <p>index.php:</p>
  
  <pre><code>$userID =10;
  if(isset($_POST['userID'])){
      switch (($_POST['userID'])){
          case  'getUSerID':
              echo $userID;       
              break;
     }    
  }
  </code></pre>
  
  <p>Javascript code:</p>
  
  <pre><code>$(document).ready(function(){
      var userID = getUserID("getUserID");
  
  function getUserID(){
   $.ajax({
          url : 'index.php',
          type: 'POST',
          data : userID,
          success: function(data, textStatus, jqXHR)
          {   
  
              return data;
          },
          error: function (jqXHR, textStatus, errorThrown)
          {
              event.preventDefault();
              alert( 'Failed to toogle.');
          }
        });
       }
  }
  </code></pre>
  
  <p>can anyone please tell me what's wrong in my code.</p>
  
  <p>Thanks in advance</p>