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
Hiten Pandya
NA
1.9k
24.5k
Not able to get the Integer value from ajax success function
Dec 22 2017 12:47 PM
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.
Reply
Answers (
4
)
how to pass parameters from view to controller in ajax
Regarding AjaxControlToolkit.HTMLEditor