Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
json data not show in table when click button jquery
ahmed salah
8y
333
1
Reply
I have url www.DevuEgypt.com/api/employees i need to display FirstName,Id,Salary in table by click button using jquery
when click button not give me any result and give me two message
I try more time but it give me error
submit handler has fired this is normal to check
error error not found this message show to me
my code as below
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name=
"viewport"
content=
"width=device-width"
/>
<title>Index</title>
<script src=
"~/Scripts/jquery-1.10.2.js"
></script>
<script>
$(function () {
$(
'#btn'
).click(function () {
alert(
"submit handler has fired"
);
$.ajax({
// type: 'POST',
url:
'www.DevuEgypt.com/api/employees'
,
data:{},
dataType:
'json'
,
success: function (data) {
$.each(data, function (index, value) {
var row = $(
"<tr><td>"
+ value.FirstName +
"</td><td>"
+ value.Id +
"</td><td>"
+ value.Salary +
"</td></tr>"
);
$(
"#myData"
).append(row);
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert(
'error: '
+ textStatus +
': '
+ errorThrown);
}
});
//return false;//suppress natural form submission
});
});
</script>
</head>
<body>
<div>
<input type=
"button"
value=
"GetData"
id=
"btn"
/>
<table id=
"myData"
></table>
</div>
</body>
</html>
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
get the value of row before changing in table if cancel clic
How to hide all div's with same class name in a page?