- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到了这个问题,并不是所有的 ajaxComplete
调用都被触发了。
我的代码
$(document)
.ajaxStart(function () {
$.blockUI();
})
.ajaxComplete(function () {
$.unblockUI();
});
这是 ajaxComplete
没有触发的代码:
$('body').on('click', '.actTimeSheetApprove', function () {
var node = $(this).parents('tr');
$.ajax({
url: '/TimeSheet/Approve/',
type: 'POST',
context: this,
data: {
__RequestVerificationToken: fnGetToken(),
id: $(this).data('id')
},
success: function (data) {
if (data == 'success') {
var table = $('#tblTimeSheetApprove').DataTable();
table.row(node).remove().draw();
console.log('SUCCESS'); //I already made sure this is called
}
}
})
})
请注意,我已经确保调用了 SUCCESS
日志。
知道为什么吗?
更新:
这是我的 Controller
[HttpPost]
[ValidateAntiForgeryToken]
[ClaimAuthorize("Role", "Manager")]
public ActionResult Approve(int id)
{
_uow.TimeSheet.Approve(id, User.Identity.Name);
_uow.Save();
return Content("success");
}
这是我的控制台日志:
最佳答案
我猜你在 $.ajax
调用中的“语法”不正确,你错过了 complete
...
成功 !== 完成
https://api.jquery.com/Ajax_Events/
通过 ajaxStart,您可以使用 load
或 ajaxSetup
来发出请求并定义成功/错误方法的行为;
同样对于调试,尝试 ajaxStop()
并查看是否一切正常。
关于javascript - ajaxComplete 不触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32942904/
如果之后,有没有办法判断调用是成功还是失败? 如果之前,有没有办法在成功函数运行后(每次调用时)运行函数? 最佳答案 您可以在多种情况下控制ajax请求: $.ajax({ // some o
我一直致力于为 AJAX 请求制作一个简单的加载函数。 AJAX 对我来说还很陌生,所以我确信我只是在做一些愚蠢的事情! ajaxStart 触发并开始加载 spinner.gif,但 ajaxCom
我正在研究用于打印 IFrame 的 Opera 解决方法。现在我们都知道打印iframe的唯一方法就是在新窗口中打开然后打印。我面临的问题是,当我的 IFrame 在新窗口中打开时,会触发一系列 a
我遇到了这个问题,并不是所有的 ajaxComplete 调用都被触发了。 我的代码 $(document) .ajaxStart(function () { $.blockUI(); })
我不明白为什么这不起作用,我已经在 stackoverflow 上查看了很多问题,但没有发现我的代码有任何问题。 我有一个#loading div,我想在ajax 调用完成后删除它。这是我的代码,从未
您好,我目前在触发 .ajaxComplete 函数时遇到问题,它应该可以在演示站点上运行。我从这里引用这个函数 http://www.bitrepository.com/a-simple-ajax-
在我的代码中,prices.html 文件未加载。我希望加载prices.html 文件,然后我想在最后表示感谢。但它直接显示感谢消息。 这样ajaxComplete()可以工作吗?
我有这个代码: $( document ).ajaxComplete(function( event, xhr, settings ) { console.log('test'); }); 我
我有一个全局 ajaxComplete 处理程序: $('body').ajaxComplete(function (event, request, settings) {
我有一个加载函数,希望代码在加载时将一些 html 写入 div,并在加载完成时显示页面。我看到了一些关于 ajaxStart 和 ajaxComplete 事件的小文章,但是我不确定如何实现它们。
一直在这个网站上工作... http://redrhinorestoration.com/wp/ 但是,当您单击“服务”,然后尝试单击“显示服务”以向上滑动服务时,它不起作用。我在这里发布并获得了一些
我正在开发一个 Google Chrome 扩展程序,以便为我经常访问的网站提供一些附加功能,这让我尝试在 AJAX 请求成功时再次运行脚本。由于站点的性质,这是必要的。 继续:简单地说,我想要做的是
我有一个用 php 编写的后端和一个用 jQuery 编写的前端..我想要做什么: 页面包含多个带有 AJAX 调用的链接(每个链接都有自己的成功/错误回调) php 后端可能会返回如下回复:{"mu
两个函数需要在 Javascript 中执行,其中一个函数应该在另一个函数完成时启动。 第一个使用 getJSON 填充数组,然后第二个将对其进行操作。 但是,getJSON 是异步的,它不会暂停执行
我使用的是 jQuery 版本 1.5.1,但这对我不起作用: $(window).ajaxComplete(function() { console.log('hello')
我希望我的 JS 的某些部分在文档准备好或 ajax 查询完成时初始化 像这样的事情: if ($(document).ready() or $(document).ajaxComplete()) {
我在单击单选按钮时发送 ajax post 请求。 // Get phone number if user selects phone option $('.rdoPhone').click
我感谢所有的帮助。我是一个初学者,几乎没有 jQuery/AJAX 经验,我一直在疯狂地试图弄清楚为什么我无法弄清楚这一点。 我正在编写一个 Facebook 页面应用程序,让用户授予权限并将视频上传
我有一个关于 .ajaxComplete() 的问题。 假设我这样做: // Register an ajaxComplete (pseudo code ish) $('#someId').ajaxC
看到这个“从 jQuery 1.8 开始,.ajaxComplete() 方法只能附加到文档。”在 jQuery 文档中,所以我想知道为什么它必须附加到文档中。正如我所尝试的,如果我将它附加到窗口或其
我是一名优秀的程序员,十分优秀!