sangeetha k

sangeetha k

  • NA
  • 207
  • 51.6k

The datas are coming inside the ajax call but it is undefine

Apr 13 2018 3:25 AM
$(document).on('click', '#btnEdit', function () {
debugger;
var empID = $(this).attr('data-id');
$.ajax({
type: 'POST',
url: '/Employee/UpdateOrEditEmployee',
data: "{Empid:'" + empID + "'}",
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");
}
});///it is not taking the value but the value is coming couldnt able to assign it to the var empid,empname and all in ajax call

Answers (6)