【发布时间】: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