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
Pravinkumar Birajdar
1.1k
584
109.4k
asp.net WebAPI showing error as [objec Object]
Jul 26 2020 7:02 AM
asp.net WebAPI showing error as
[objec Object]
web api
public
class
BrandsController : ApiController
{
public
List<Brand> Get()
{
EFDBFirstDatabaseEntities db =
new
Models.EFDBFirstDatabaseEntities();
List<Brand> brands = db.Brands.ToList();
return
brands;
}
}
in view:
@{
ViewBag.Title =
"Index"
;
Layout =
"~/Views/Shared/_LayoutPage1.cshtml"
;
}
<div
class
=
"container"
>
<h2>Brands</h2>
<button type=
"button"
id=
"btnGetBrands"
class
=
"btn"
>Get Brands</button>
<table
class
=
"table brandsTable"
>
<tr>
<th>Brand ID</th>
<th>Brand Name</th>
</tr>
</table>
<script type=
"text/javascript"
>
$(
"#btnGetBrands"
).click(() => {
$.ajax({
type:
"GET"
, url:
"/api/Brands"
, success: (response) => {
for
(var i = 0; i < response.length; i++) {
var br = response[i];
var str =
"<tr><td>"
+ (i + 1) +
"</td> <td>"
+ br.BrandName +
"</td></tr>"
;
$(
".brandsTable"
).append(str);
}
}, error: (err) => {
alert(err);
console.log(err);
}
});
});
</script>
</div>
Please help me...
Reply
Answers (
5
)
In dotnet When used Framework7 button click not working
About File Upload in MVC