此页面上的脚本可能正忙,或者可能已停止响应。 Asp.net

时间:2013-05-18 09:56:10

标签: javascript jquery asp.net

我有一个页面在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();
                 }
             }
         });

请帮我做点什么。

2 个答案:

答案 0 :(得分: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"); }
             });
           }
      });

答案 1 :(得分:0)

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

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

-add class .asyncupload input { width:100%!important; }到你的css文件。