TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sangeetha k
NA
207
51.3k
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);
}
Reply
Answers (
7
)
Need Code for required problem.
The datas are coming inside the ajax call but it is undefine