Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用定位标记创建查询字符串时出错_Javascript_Jquery_Angularjs_Asp.net Mvc - Fatal编程技术网

Javascript 使用定位标记创建查询字符串时出错

Javascript 使用定位标记创建查询字符串时出错,javascript,jquery,angularjs,asp.net-mvc,Javascript,Jquery,Angularjs,Asp.net Mvc,当我使用锚标记传递查询字符串时,我得到了我的url,但问题是processorId=51重复了两次 我的绳子就这样来了 MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?处理器ID=51&bankId=51&bankId=2866 但我被期待着 MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?处理器ID=51&bankId=2866 请给我一个解决办法

当我使用锚标记传递查询字符串时,我得到了我的url,但问题是processorId=51重复了两次 我的绳子就这样来了 MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?处理器ID=51&bankId=51&bankId=2866

但我被期待着

MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?处理器ID=51&bankId=2866

请给我一个解决办法

+ "<li><a target='_blank'  href='/MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?processorId=' >View By Date</a></li>"

 + "<li><a target='_blank' href='/MonthlySettlementAlgorithm/MonthlySettlementResultViewByBank?processorId=' >View By Bank</a></li>"

    Jquery Code 

         $('.dropdown-menu.features li a').each(function () {
            if ($(this).attr('href'))
            {
                $(this).attr('href', $(this).attr('href') + selectedProcessorIds +'&bankId='+ selectedBankIds);
            }
        });
 $('.dropdown-menu.features li a').each(function () {

    var href = $(this).attr('href');
    if (href) {
        var requiredArray = href.split('?');

        if (requiredArray.length > 1) {
            var tempProcString = "processorId=" + selectedProcessorIds;
            var tempBankString = "&bankId=" + selectedBankIds;
            var tempDate = "&snapshotDate=" + $('#txtDate_FirstDateValue').val();
            requiredArray[1] = tempProcString + tempBankString + tempDate;
            console.log(requiredArray[1]);
        }

        //finally updating href
        $(this).attr('href', requiredArray.join('?'));
    }
});
+“
  • ” +“
  • ” Jquery代码 $('.dropdown-menu.features li a')。每个(函数(){ if($(this.attr('href')) { $(this.attr('href',$(this.attr('href')+selectedProcessorIds+'&bankId='+selectedBankIds); } });
    我终于找到了解决方案

    + "<li><a target='_blank'  href='/MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?processorId=' >View By Date</a></li>"
    
     + "<li><a target='_blank' href='/MonthlySettlementAlgorithm/MonthlySettlementResultViewByBank?processorId=' >View By Bank</a></li>"
    
        Jquery Code 
    
             $('.dropdown-menu.features li a').each(function () {
                if ($(this).attr('href'))
                {
                    $(this).attr('href', $(this).attr('href') + selectedProcessorIds +'&bankId='+ selectedBankIds);
                }
            });
    
     $('.dropdown-menu.features li a').each(function () {
    
        var href = $(this).attr('href');
        if (href) {
            var requiredArray = href.split('?');
    
            if (requiredArray.length > 1) {
                var tempProcString = "processorId=" + selectedProcessorIds;
                var tempBankString = "&bankId=" + selectedBankIds;
                var tempDate = "&snapshotDate=" + $('#txtDate_FirstDateValue').val();
                requiredArray[1] = tempProcString + tempBankString + tempDate;
                console.log(requiredArray[1]);
            }
    
            //finally updating href
            $(this).attr('href', requiredArray.join('?'));
        }
    });
    

    当您在js中构建
    a
    标记时,首先设置
    href='/monthlysetletmentalgorithm/monthlysetletmentresultviewbydate'
    。我已经尝试了这一行,但没有得到确切的结果