作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的一个页面在 Firefox 中出现此错误:
A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.
这是我的 jquery 代码:
function uploadComplete(sender, args) {
var imgDisplay = $get("imageEmployeeTemp");
var img = new Image();
img.onload = function () {
imgDisplay.style.cssText = "height:100px;width:100px";
imgDisplay.src = img.src;
};
img.src = "/Resources/Images/Employee/" + args.get_fileName();
}
$(document).ready(function () {
$('#TxBx_BasicSalary').focusout(function () {
var EmployeeId = $('#Hid_EmpID').val();
if (EmployeeId == 0) {
return;
}
$.ajax({
type: "POST",
cache: false,
contentType: "application/json; charset=utf-8",
url: '/WebService/IncDedWebService.asmx/GetInceDed',
data: '{ "id": "' + EmployeeId + '" }',
dataType: 'json',
success: function (data) {
var data = $.parseJSON(data.d)
var TotalIncentives = data["TotalIncentives"];
var TotalDeduction = data["TotalDeduction"];
var BasicSalary = $("#TxBx_BasicSalary").val();
var GrossSalary = parseInt(BasicSalary) + parseInt(TotalIncentives)
$('#Ltrl_GSalary').html(GrossSalary);
$('#Hid_GSalary').val(GrossSalary);
$('#Ltrl_NetSalary').html(GrossSalary - parseInt(TotalDeduction));
$('#Hid_NetSalary').val(GrossSalary - parseInt(TotalDeduction));
},
error: function () { alert("error"); }
});
});
var id = "#<%= Rtb_PayMode.ClientID %>";
var bool = false;
$(id).click(function () {
HideShowRows();
bool = true;
});
if (!bool) {
HideShowRows();
}
function HideShowRows() {
var BankInfo = $('#BankInfo');
var BankAccount = $('#BankAccount');
if ($('#<%= Rtb_PayMode.ClientID %> input:checked').val() == '1') {
BankInfo.hide();
BankAccount.hide();
}
else {
BankInfo.show();
BankAccount.show();
}
}
});
请帮我做什么。
最佳答案
您可以尝试设置一个标志来停止多个并发的 ajax 请求:
$(document).ready(function () {
var inProgress = false;
$('#TxBx_BasicSalary').focusout(function () {
if(!inProgress){
inProgress = true;
var EmployeeId = $('#Hid_EmpID').val();
if (EmployeeId == 0) {
return;
}
$.ajax({
type: "POST",
cache: false,
contentType: "application/json; charset=utf-8",
url: '/WebService/IncDedWebService.asmx/GetInceDed',
data: '{ "id": "' + EmployeeId + '" }',
dataType: 'json',
success: function (data) {
inProgress = false;
var data = $.parseJSON(data.d)
var TotalIncentives = data["TotalIncentives"];
var TotalDeduction = data["TotalDeduction"];
var BasicSalary = $("#TxBx_BasicSalary").val();
var GrossSalary = parseInt(BasicSalary) + parseInt(TotalIncentives)
$('#Ltrl_GSalary').html(GrossSalary);
$('#Hid_GSalary').val(GrossSalary);
$('#Ltrl_NetSalary').html(GrossSalary - parseInt(TotalDeduction));
$('#Hid_NetSalary').val(GrossSalary - parseInt(TotalDeduction));
},
error: function () { alert("error"); }
});
}
});
关于javascript - 此页面上的脚本可能正忙,或者可能已停止响应。 ASP.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16622931/
我是一名优秀的程序员,十分优秀!