Javascript 使用定位标记创建查询字符串时出错
当我使用锚标记传递查询字符串时,我得到了我的url,但问题是processorId=51重复了两次 我的绳子就这样来了 MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?处理器ID=51&bankId=51&bankId=2866 但我被期待着 MonthlySettlementAlgorithm/MonthlySettlementResultviewByDate?处理器ID=51&bankId=2866 请给我一个解决办法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 请给我一个解决办法
+ "<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'
。我已经尝试了这一行,但没有得到确切的结果