[英]counter - Update the number if click increase +1
I want every time a user clicks a button, increases +1 in the counter, and Ajax work every time if user click. 我希望每次用户单击按钮时都增加计数器+1,并且每次用户单击时Ajax都可以工作。
This is just for a test with AJAX and the function will work every time if user click on the button. 这仅用于使用AJAX进行的测试,如果用户单击该按钮,则该功能将每次运行。
My code in HTML: 我的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>
Function .js
: 函数
.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);
}
});
}
its work: 是工作:
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 (...)
Then I will make a connection class with the bank and a field where it will check if the counter number already exists and if not, +1 然后,我将与银行建立连接类,并在该字段中检查计数器编号是否已经存在,如果没有,则+1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.