sangeetha k

sangeetha k

  • NA
  • 207
  • 48.9k

y ajax method is hittingthe action method

Apr 13 2018 2:20 AM
$(document).on('click', '#btnEdit', function () {
debugger;
var empID = $(this).attr('data-id');
$.ajax({
type: 'POST',
url: '/Employee/UpdateOrEditEmployee',
data: "{EmployeeID:'" + empID + "'}",
ccatch: false,
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (data) {
debugger;
if (data == 0 || data == null) {
debugger;
data.length == 0;
//clear();
$('#txtEmpID').val();
$('#txtEmpName').val();
$('#txtDesignation').val();
$('#txtEmpimage').val();
$('#txtSalary').val();
$('#txtEmail').val();
$('#txtDepartment').val();
}
else if (data.length!=0 && data!=0) {
debugger;
var Empid = data.Empid;
var EmployeeName = data.Empname;
var Designation = data.Designation;
var Empimage = data.Empimage;
var Employeesalary = data.Salary;
var Department=data.Department;
if (Empid != null) {
$('#txtEmpID').val(Empid);
}
if (EmployeeName != null) {
$('#txtEmpName').val(EmployeeName);
}
if (Designation != null) {
$('#txtDesignation').val(Designation);
}
if (Empimage != null) {
$('#txtEmpimage').val(Empimage);
}
if (Employeesalary != null) {
$('#txtSalary').val(Employeesalary);
}
if (Employeesalary != null) {
$('#txtEmail').val(Employeesalary);
}
if (Department != null) {
$('#txtDepartment').val(Department);
}
}
$('#EditModal').modal('show');
},
failure: function (data) {
alert("Failed");
},
error: function (data) {
alert("error");
}
});
});
});
 
 #method that needed to be hit
[HttpPost]
public JsonResult UpdateOrEditEmployee( int id)
{
try
{
EmployeeBusiness EmpBusiness = new EmployeeBusiness();
List<EmployeeEntity> emp = null;
emp = EmpBusiness.EditEmployee(id);
return Json(emp);
}
 
 

Answers (7)