Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
Not able to get the Integer value from ajax success function
Hiten Pandya
Dec 22 2017 12:47 PM
204
Reply
Hello all, I am new to Web API and try to get the HREmpID from my ajax response but unfortunetly I am getting undefined.Below screen shot will provide more information in case if you need.
And in the below code is of ajax code that will get the records from the api
$(document).ready(
function
() {
var
r =
new
Array();
var
j = -1;
r[++j] =
'<table border = 1><thead><tr><th>HREmpID</th><th>Name</th><th>Address</th><th>City</th><th>Action</th></tr></thead><tbody>'
$.ajax({
type:
"GET"
,
url:
"/api/EmployeeAPI/"
,
success:
function
(result) {
//alert(result[0]["FirstName"]);
for
(
var
i
in
result) {
var
data = result[i];
alert(result[0][
"HREmpID"
]);
r[++j] =
'<tr>'
;
r[++j] =
'<td>'
;
r[++j] = data.HREmpID;
r[++j] =
'</td>'
;
r[++j] =
'<td>'
;
r[++j] = data.FirstName +
" "
+ data.LastName;
r[++j] =
'</td>'
;
r[++j] =
'<td>'
;
r[++j] = data.Address;
r[++j] =
'</td>'
;
r[++j] =
'<td>'
;
r[++j] = data.City;
r[++j] =
'</td>'
;
r[++j] =
'</tr>'
;
}
r[++j] =
'</tbody></table>'
;
$(
"#empDetails"
).html(r.join(
''
));
}
});
});
but I always getting the undefined for HRempID. I don't know what is going wrong ? any help will be appreciate. Thanks in advance.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
how to pass parameters from view to controller in ajax
Regarding AjaxControlToolkit.HTMLEditor