如何检索Jquery所需的数据

如何检索Jquery所需的数据,jquery,ajax,Jquery,Ajax,大家好,我是新来学习j-query的,很抱歉我的英语很差 这是我的ajax调用 // Get All Designaions on Department Change $("#departmentDropdownForBody").change(function (evt) { var departmentId = $("#departmentDropdownForBody").val(); //Preve

大家好,我是新来学习j-query的,很抱歉我的英语很差

这是我的ajax调用

// Get All Designaions on Department Change
             $("#departmentDropdownForBody").change(function (evt) {
                var departmentId = $("#departmentDropdownForBody").val();
                //Prevent the browser default
            evt.preventDefault();
            $.ajax({
                type: 'GET',
                url: '@Url.Action("GetDesignationFilteredByIds", "Designation")',
                data: { CompanyId: 0, BusinessUnitId: 0, DepartmentId: departmentId },
                dataType: 'JSON',
                traditional: true,
                success: function (response) {
                    $('#desigTbody').html('');
                    var tRow = '';
                    for (var i = 0; i < response.length; i++) {
                        tRow += '<tr><td class="hide" id="depId">' + response[i].DepartmentId + '</td>'
                        tRow += '<tr><td class="hide" id="desId">' + response[i].DesignationId + '</td>'
                        tRow += '<tr><td>' + response[i].CompanyName + '</td>'
                        tRow += '<td>' + response[i].BusinessUnitName + '</td>'
                        tRow += '<td>' + response[i].DepartmentName + '</td>'
                        tRow += '<td>' + response[i].DesignationName + '</td>'
                        tRow += '<td><button type="button" id="editBtn" onclick="getDesignation(this.DepartmentId,this.DesignationId)" data-toggle="modal" data-target="#modal-default" ><span class="fa fa-edit" /></button></td></tr>';
                    };
                    $('#desigTbody').append(tRow);
                },
                error: function () { }
            });
        });
//获取部门变更时的所有指定
$(“#departmentDropdownForBody”).更改(功能(evt){
var departmentId=$(“#departmentDropdownForBody”).val();
//阻止浏览器默认设置
evt.preventDefault();
$.ajax({
键入:“GET”,
url:'@url.Action(“GetDesignationFilteredById”,“指定”),
数据:{CompanyId:0,BusinessUnitId:0,DepartmentId:DepartmentId},
数据类型:“JSON”,
传统的:是的,
成功:功能(响应){
$('#desigTbody').html('');
var-tRow='';
对于(变量i=0;i

请阅读这个ajax调用。我想在我的按钮上传递两个参数,单击每行的打印。请帮忙

我建议您使用cutsom
data-*
属性保存任意数据,这些属性可以使用


注意:HTML中的标识符必须是唯一的。

哪两个参数?我可以看到您正在传递
部门ID
以及
公司ID
业务单元ID
硬编码到
0
。非常感谢。
tRow += '<td><button type="button" class="editBtn" data-departmentid="' + response[i].DepartmentId + '" data-designationid="' + response[i].DesignationId + '" data-toggle="modal" data-target="#modal-default" ><span class="fa fa-edit" /></button></td></tr>';
$('#desigTbody').on('click', '.editBtn', function () {
    var departmentid = $(this).data('departmentid');
    var designationid = $(this).data('designationid');
    getDesignation(departmentid, designationid);
});