使用ajax调用方法来调用控制器 [英] Using ajax call method to call controller
本文介绍了使用ajax调用方法来调用控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的视图上有一个结果表,显示我想要的是在显示表格几秒钟后向控制器发出ajax调用
在我清理我的数据库的地方,桌子不应该受到影响。
我的尝试:
i have a result table on my views which is getting displayed what i want is after few seconds of displaying the table a ajax call is made to a controller
where i carry out cleaning of my database the table should not be affected .
What I have tried:
<script type="text/javascript" src="~/Scripts/jquery.unobtrusive-ajax.js">
</script>
<script type="text/javascript">
var timer, delay = 100000;
timer = setInterval(function () {
$.ajax({
type: 'POST',
url: 'ShowResult/DeleteDatabase',
success:
function (response) {
console.log("Success")
},
error:
function (response) {
console.log("failure")
},
});
},delay)
</script>
推荐答案
.aj ax({
type:' POST',
url:' ShowResult / DeleteDatabase',
成功:
function (响应){
console .log( 成功)
},
错误:
function (响应){
console .log( failure)
},
});
},延迟)
< / script>
.ajax({ type: 'POST', url: 'ShowResult/DeleteDatabase', success: function (response) { console.log("Success") }, error: function (response) { console.log("failure") }, }); },delay) </script>
使用setTimeout而不是setInterval
窗口setTimeout()方法 [ ^ ]
Use setTimeout rather than setInterval
Window setTimeout() Method[^]
这篇关于使用ajax调用方法来调用控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文