counter - 如果点击增加 +1 则更新数字

counter - Update the number if click increase +1

我希望每次用户单击一个按钮时,在计数器中增加 +1,并且 Ajax 每次用户单击都有效。

这只是针对 AJAX 的测试,如果用户单击按钮,该功能将每次都起作用。

我的代码在HTML:

<html>
<head>
<meta charset="UTF-8">

<title>Demo</title>
<script src="jquery-3.1.1.js"></script>
<script src="JS.js"></script>
<!--script src="JS2.js"></script-->
</head>

<body>
<button id="1" onclick="dadosLog()">
       Login    


</body>
</html>

函数.js:

var numberOrigin = 0  // 
function dadosLog (){
           numberOrigin++;
           var obj = login("xxxLog", "xxxxxxxPassword", numberOrigin); 
        }

        // Function 2 before function 1 its OK
        function function2(otherParameter, numberOrigin){
        console.log(xxxxxx);
          $.ajax({
            type: 'POST',
            dataType: 'json',
            contentType: "application/json",
            url: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/request/create',
            data: JSON.stringify({
              "synchronize":false,
              "sourceRequest":{
                  "numberOrigin":numberOrigin,
                  "description": "test"
                   }
                  },
                 }),
              success:function(output) {
              console.log(output);
              alert(output.request.number)
              },
              error:function(output) {
                return '0';
              console.log(output);
             }
          });
        }

它的作品:

var counter = 10; // Enter the value you want to start the counter


function Function1(){
  var obj = teste("xxxxxxx", "xxxxxxxxxxx", counter);
  counter++;
}

var obj;

function teste (NameV, NameV2, counter){
  counter +=1;
    // function (...)

然后我将与银行建立连接 class 并在其中检查柜台号码是否已经存在,如果不存在,+1