为什么这个jQuery ajax按钮点击事件在MVC4 C#.net中多次触发?

时间:2016-07-18 14:05:46

标签: javascript c# jquery ajax asp.net-mvc-4

我正在研究MVC4 C#.Net项目,当我尝试时 单击按钮('#btn_rightArw_Dwn'),然后在MVC4中多次触发ajax调用。为什么会这样?请查看下面的jQuery代码。

enter image description here

下面我添加了jQuery代码。



$("#btn_rightArw_Dwn").click(function() {
  $('.fade_bg').show();
  var Masterid = $('#MastersId').val();
  var pgm_id = $('#program1').val();
  if ($('#rdclick').val() == "0") {

    $.ajax({

      url: "/DataInput/Arrow_Load_Down?Id=" + Masterid + "&flag=" + "Right" + "&type=" + 0 + "&pgm_id=" + pgm_id,
      async: true,
      data: {},
      success: function(data) {
        $('#DVmaster').html(data);
        $('#btn_rightArw1').attr('hidden', false);
        $('#btn_LeftArw1').attr('hidden', false);
        var production_id = $('#program1').val();

        $.ajax({

          url: "/DataInput/Arrow_Load_Details_Down?Id=" + Masterid + "&flag=" + "Right" + "&ProductnSts_id=" + pgm_id + "&type=" + 0,

          async: false,
          data: {},
          success: function(data) {

            $('#DVDetails').html(data);
            $('#DVDetails').show();
            $('#btn_rightArw_Dwn').attr('hidden', false);
            $('#btn_LeftArw_dwn').attr('hidden', false);

          },
          error: function(html) {
            $('.fade_bg').hide();
          }
        });

        var channelid = $("#channel1").val();
        var starttime = $("#StartTime").val();
        var Endtime = $("#EndTime").val();
        var date = $("#Date").val();
        var Vimpact = $("#Viewers").val();
        var gradeid = $("#grade1").val();
        var seclength = $("#Seconds option:selected").text();
        var Daypartid = $('#daypartid').val();
        var itemid = $('#item1 option:selected').val();
        var brandid = $("#brand1 option:selected").val();




        $.ajax({
          url: "/DataInput/Print_Labels_in_Edit?starttime=" + starttime + "&finishtime=" + Endtime + "&date=" + date + "&channelid=" + channelid + "&impact1=" + Vimpact + "&Seclength=" + seclength + "&gradesid=" + gradeid + "&itemid=" + itemid + "&brandid=" + brandid,

          cache: false,
          success: function(html) {
            var labels = html.split(',');
            var daypartname = labels[0];
            var CPH = labels[1];
            var TVR = labels[2];
            var Mediavalue = labels[3];
            var daypartid = labels[4];
            $('.fade_bg').hide();
            $('#lblDaypart').text(" " + daypartname);
            $("#lblCPH").text('£' + " " + CPH);
            $('#lblTvr').text(" " + TVR);
            $('#lblMediaValue').text(" " + "£ " + Mediavalue);
            $('#daypartid').val(daypartid);



          },
          error: function(html) {
            $('.fade_bg').hide();
          }
        });

      }

    });
  }
});




提前致谢。

0 个答案:

没有答案