【问题标题】:counter - Update the number if click increase +1计数器 - 如果单击增加 +1,则更新数字
【发布时间】:2016-12-01 17:40:01
【问题描述】:

我希望每次用户单击按钮时,计数器都会增加 +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);
             }
          });
        }

【问题讨论】:

  • 你在nodejs中使用ajax?

标签: javascript jquery ajax node.js counter


【解决方案1】:

它的工作:

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 (...)

然后我将与银行建立一个连接类和一个字段,它将检查柜台号码是否已经存在,如果不存在,+1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多