accessing global variable in a function and putting this variable's value in ajax
- var preCounter = 0;
- var counter = 0;
- $("#addQ").click(function(){
- $.ajax({
- url : "qtemp.php",
- type : "post",
- data : "axn=qtype&cntr="+counter+"&pcntr="+preCounter
- }).done( function(msg) {
- });
- });
- });
'preCounter' is not passing value in ajax while varible 'counter' passing value. please help me, thanks in advance