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
zeeshan akram
1.4k
325
18k
How to return two object using json and receive using jquery
Mar 3 2020 6:39 AM
Hi, these are two objects and I want to access these two objects on view using jquery. I have tried a lot of but I could receive these two objects. when I remove one object data will be received successfully but two objects at a time I could not access.
any expert can you tell me combine two objects and received in view using jquery.
ECommercedbEntities db =
new
ECommercedbEntities();
var productl = (from p
in
db.Products
where p.ProductID == id
select
new
{
PName = p.PName.Trim()
}).FirstOrDefault();
var productD = (from pd
in
db.ProductDetails
join p
in
db.Products on pd.ProductID equals p.ProductID
where pd.ProductID == id
select
new
{
ProductID = pd.ProductID,
OS = pd.OS,
}).ToList();
return
Json(,JsonRequestBehavior.AllowGet); // i have try this
return
Json(new{
productl,
productD
},JsonRequestBehavior.AllowGet) // but i could not receive in jquery
jquery access
function
GetProductByID(ID)
{
$.ajax({
url:
"/Items/GetProd/"
+ ID,
typr:
"GET"
,
contentType:
"application/json;charset=UTF-8"
,
dataType:
"json"
,
success:
function
(res) {
$(
'#PName'
).val(res.Model);
$(
'#mProduct'
).modal(
'show'
);
$(
'#btnUpdate'
).show();
$(
'#btnSave'
).hide();
},
error:
function
(errormessage) {
alert(errormessage.responseText);
}
});
return
false
;
}
Reply
Answers (
4
)
Bind Drop down in mvc.
How to create dynamic model using created dynamic table?