jquery ajax调用返回双重结果

时间:2016-08-11 20:23:40

标签: jquery ajax

我正在使用ajax调用页面。在该页面上有一些表单元素。当在表单元素上按下保存时,我的formcheck脚本会触发声明字段为空时不是。经过一堆抨击后,我发现由于某种原因,该页面正在重复。即使我在我的网站上看不到副本,代码确实看到了它,这就是为什么它看到一个空文本字段,即使我已经填写了它。我如何杀死这个重复的页面?这是我的页面。仅供参考,它会经历循环,因为我正在克隆字段,我需要检查生成的所有字段。

formcheck代码

  $(document).on('click','#but_uploadSubmitT',function(e){
    e.preventDefault();

    save = true; // reset the save variable before the loop

    $('.carrier').each(function(){
      var value = $(this).val();
      console.log('*** class '+value);

        if(value==''){
            alert('Please enter a Carrier/Mode/Account before saving');
            save = false;
            $(this).focus();
            return false;
        }
    });

    if(save){
      $('#uploadSpinner').show();
      $('#uploadFormT').submit();
    }
  });

这是用ajax加载的页面(只是相关部分):

    <td><input name="carrier" type="text" id="carrier" style="width:225px;" class="commas carrier"></td>

Ajax电话:

  $(document).on('click','#import', function(e){
    e.preventDefault();

    $('.modal-dialog').removeClass('modal-lg modal-sm');

    $('.mHeader').html('<h3>Upload File <i class="fa fa-spinner fa-spin" style="display:none" id="uploadSpinner"></i></h3>');

    $('.mBody').load('/ajax/upload.asp?clientID=5',function(){

      $('.mFooter').html($('#mFooterC').html()); 

    });

    $('#mWindow').modal();

0 个答案:

没有答案
相关问题