jquery - 我是这个 jquery 的新手,无法在下面的代码中找到语法错误
问题描述
我在链接按钮中的上述代码中遇到语法错误,其中 jquery 函数在 ajax 调用的成功函数中单击链接时被调用。
请协助我
<script type="text/javascript">
function showdiv(id, sender, amt) {
debugger;
// alert(id);
// debugger;
$('#frmPayment')[0].src = window.appBaseUrl + '/UploadHistory/RenderTest/';
var searchValue = $("#hdnScreenType").val();
$('#lblTransactionQBONumber').text(id);
$('#tbPaymentAmount').val(amt);
if (searchValue == "2") {/*IT is bill payment screen*/
// $("#myModal").width(1000).height(800);
$('#frmPayment').width(400).height(500);
// $('#frmPayment').css('display', 'block');
$('#divDwnLdLink').css('display', 'none');
$('#frmPayment')[0].src = window.appBaseUrl + '/BillDetailAndPayment?id=' + searchValue + '&searchValue=' + id;
//setTimeout(function () { $('#billpaymentdiv').css('display', 'block') }, 0);
$('#billpaymentdiv').css('display', 'block');
}
else {
$('#billpaymentdiv').css('display', 'none');
$('#divDwnLdLink').css('display', 'block');
var _url = "" + window.appBaseUrl + '/downloadPopup.aspx?id=' + id + '&searchValue=' + searchValue + "";
$('#downloadLink').attr('href', _url)
}
return false;
}
function closeMe() {
alert("Payment Added.");
$('#frmPayment')[0].src = window.appBaseUrl + '/test.aspx';
$('#billpaymentdiv').css('display', 'none');
$('#divDwnLdLink').css('display', 'none');
location.reload();
// $('#modalClose').click();
}
</script>
<script>
$('#ddBillStatus').change(function () {
var Value = $(this).find(":selected").val()
var selectid = { "value": Value }
$.ajax({
url: "/UploadHistory/UploadHistory",
data: JSON.stringify(selectid),
type: 'POST',
contentType: 'application/json; charset=utf-8',
success: function (data) {
// Variable data contains the data you get from the action method
$('#tableprocesshistory').show();
var row = "";
row += "<thead><tr><th>Created Date</th><th>Uploaded File Name</th><th>QBO-Number</th><th>Total Amount</th><th>Vendor Name</th><th>Invoice Date</th><th>Reference Number</th><th id='paymentHeader' >Payment</th></tr></thead>";
$.each(data, function (index, item) {
row += "<tr><td>" + item.CreatedDateFormated + "</td><td>" + item.FileUniqueName + "</td><td class='nr'><span>" + item.TransactionQBONumber + "</span> </td><td>" + item.TransactionTotalAmount + "</td><td>" + item.vendorName + "</td><td>" + item.InvoiceDate + "</td><td>" + item.RefNumber + "</td><td><a href='#' onclick='String.format('javascript:return showdiv(\"{0}\",{1},\"{2}\")', " + item.TransactionQBONumber + "," + item.TransactionTotalAmount + ")' id='myLinkButton1' >Action</a></td></tr>";
// var myrow = $(this).closest("tr"); // Find the row
// var abc = myrow.find(".nr").text;
//$("#lblTransactionQBONumber").html(abc);
});
$("#tableprocesshistory").html(row);
//$(".Pager").ASPSnippets_Pager({
// ActiveCssClass: "current",
// PagerCssClass: "pager",
// PageIndex: data.PageIndex,
// PageSize: data.PageSize,
// RecordCount: data.RecordCount
// });
}
});
//var url = "/UploadHistory/ddBillStatus_SelectedIndexChanged/";
//window.location.href = url;
});
</script>
我已经编辑了我的代码并添加了 show div 功能。请看一下。帮我解决问题,因为我无法在单击操作链接时调用 show div 函数
解决方案
我在操场上创建示例,请参见此处。我只是使用/echo/json/
url 进行响应模拟。
$('#ddBillStatus').change(function () {
var Value = $(this).find(":selected").val()
var selectid = { "value": Value }
$.ajax({
url: "/echo/json/",
data: { json: JSON.stringify( jsonData[selectid.value] ) },
type: 'POST',
contentType: 'application/json; charset=utf-8',
success: function (data) {
// Variable data contains the data you get from the action method
$('#tableprocesshistory').show();
var row = "";
row += "<thead><tr><th>Created Date</th><th>Uploaded File Name</th><th>QBO-Number</th><th>Total Amount</th><th>Vendor Name</th><th>Invoice Date</th><th>Reference Number</th><th id='paymentHeader' >Payment</th></tr></thead>";
$.each(data, function (index, item) {
row += "<tr><td>" + item.CreatedDateFormated + "</td><td>" + item.FileUniqueName + "</td><td class='nr'><span>" + item.TransactionQBONumber + "</span> </td><td>" + item.TransactionTotalAmount + "</td><td>" + item.vendorName + "</td><td>" + item.InvoiceDate + "</td><td>" + item.RefNumber + "</td><td><a href='#' onclick='return showdiv(\"" + item.TransactionQBONumber + "\",\"" + item.TransactionTotalAmount + "\")' id='myLinkButton1' >Action</a></td></tr>";
});
$("#tableprocesshistory").html(row);
}
});
});
推荐阅读
- unit-testing - Angular:ng测试运行但不执行测试用例
- android - 用户未连接到互联网时如何显示自定义错误布局?
- android - Manifest 中定义的启动模式是覆盖通过意图标志调用的启动模式还是相反?
- angular - 订阅路由以获取可观察性并在一次订阅中对其进行处理
- vba - VBA - 在公式中使用 Columns()
- xamarin.forms - apk 已安装,但不适用于 android 6.0 版本,只有 xamarin 形式
- spring-mvc - Struts 1.2.9 到 Spring MVC 迁移 - ActionForms 的处理范围
- recursion - 动态内存分配查询
- jboss - 从 MRI 控制台接收图像的问题
- python - 如何从 Keras.layers 实现 Merge