accessing global variable in a function and putting this variable's value in ajax

accessing global variable in a function and putting this variable's value in ajax

  1. var preCounter = 0;
  2. var counter = 0;
  3. $("#addQ").click(function(){
  4. $.ajax({
  5. url : "qtemp.php",
  6. type : "post",
  7. data : "axn=qtype&cntr="+counter+"&pcntr="+preCounter
  8. }).done( function(msg) {
  9. });
  10. });

  11. });
'preCounter' is not passing value in ajax while varible 'counter' passing value. please help me, thanks in advance