3

我有一个页面在 Firefox 中给了我这个错误:

此页面上的脚本可能正忙,或者它可能已停止响应。您现在可以停止脚本,也可以继续查看脚本是否会完成。

这是我的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();
                 }
             }
         });

请帮我做什么。

4

2 回答 2

0

我在使用 ajaxToolkit:AsyncFileUpload 时遇到了同样的问题。css 有一个解决方法;

CssClass="asyncupload"-在您的 AsyncFileUpload 中应用,

- 将类添加.asyncupload input { width:100%!important; }到您的 css 文件。

于 2013-11-21T11:42:16.883 回答
0

您可以尝试设置一个标志来停止多个同时 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"); }
             });
           }
      });
于 2013-07-31T16:12:19.673 回答