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;
- }