Hi, I want to show data in grid function is calling but not show in the grid. I debug the code I can see the id value when the cursor reaches the $.ajax then directly go to the end of brackets, I don't know what is a problem any expert can you tell where I am wrong.
Any Expert can you tell me How I display this JSON format data in grid and Input Field if you feel any mistake kindly me How to resolve this issue.
**JSON Result:**
- {
- "listProducts": {
- "Customers": [],
- "P_Color": {
- "Products": [],
- "C_ID": 3,
- "C_Name_OR_Code": "Green "
- },
- "P_Size": {
- "Products": [],
- "S_ID": 2,
- "S_Size": "MediumNa "
- },
- "ProductDetail": {
- "ProductID": 6,
- "PDescription": "s",
- "Model": "s ",
- "Condition": "s ",
- "OS": "s",
- "DualSim": "s ",
- "TouchScreen": "ss ",
- "ScreenSize": "s ",
- "ProcessorType": "s ",
- "Camera": "s ",
- "RAM": "s ",
- "InternalMemory": "s ",
- "Wifi": "s ",
- "BatteryLife": "s ",
- "Discount": 54.0,
- "Other": "s",
- "ImageUrl": "~/upload/20095729TERI NAZAR Song LYRICS.jpg"
- },
- "ProductType": {
- "Products": [],
- "PType_ID": 1,
- "P_Name": "mobile ",
- "P_Description": "mobile",
- "Active": false
- },
- "ProductID": 6,
- "PName": "s ",
- "UnitWeight": 0.0,
- "UnitInStock": 4.0,
- "P_SizeID": 2,
- "P_Color_ID": 3,
- "PType_ID": 1,
- "ManificturedPrice": 52.0
- },
- "listProductDetails": [
- {
- "Product": {
- "Customers": [],
- "P_Color": {
- "Products": [],
- "C_ID": 3,
- "C_Name_OR_Code": "Green "
- },
- "P_Size": {
- "Products": [],
- "S_ID": 2,
- "S_Size": "MediumNa "
- },
- "ProductType": {
- "Products": [],
- "PType_ID": 1,
- "P_Name": "mobile ",
- "P_Description": "mobile",
- "Active": false
- },
- "ProductID": 6,
- "PName": "s ",
- "UnitWeight": 0.0,
- "UnitInStock": 4.0,
- "P_SizeID": 2,
- "P_Color_ID": 3,
- "PType_ID": 1,
- "ManificturedPrice": 52.0
- },
- "ProductID": 6,
- "PDescription": "s",
- "Model": "s ",
- "Condition": "s ",
- "OS": "s",
- "DualSim": "s ",
- "TouchScreen": "ss ",
- "ScreenSize": "s ",
- "ProcessorType": "s ",
- "Camera": "s ",
- "RAM": "s ",
- "InternalMemory": "s ",
- "Wifi": "s ",
- "BatteryLife": "s ",
- "Discount": 54.0,
- "Other": "s",
- "ImageUrl": "~/upload/20095729TERI NAZAR Song LYRICS.jpg"
- }
- ],
- }
**Get Product Function to fetch for one Value** //JSON format already share above
- public ActionResult GetProduct_Detail(int id)
- {
- var resultProdD = _IProducts.GetProductByID(id);
- JsonSerializerSettings jss = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore };
- var result = JsonConvert.SerializeObject(resultProdD, Formatting.Indented, jss);
- return Json(result, JsonRequestBehavior.AllowGet);
- }
**HTML View**
**Jquery Function**

- <script type="text/javascript">
- $(document).ready(function () {
- debugger;
- var baseUrl = (window.location).href;
- var id = baseUrl.substring(baseUrl.lastIndexOf('=') + 1);
- list_ProductDetail(id);
- });
- function list_ProductDetail(id)
- {
- $.ajax({
- url: "/Items/GetProduct_Detail",
- type: "GET",
- contentType: "application/json;charset=utf-8",
- dataType: "json",
- data: { id: id },
- success: function (result) {
- $('#PName').val(result.PName);
- $('#ManificturedPrice').val(result.ManificturedPrice);
- $('#UnitWeight').val(result.UnitWeight);
- $.each(result, function (key, item) {
- var html = '';
- html += '<tr>';
- html += '<td>' + item.ProductID + '</td';
- html += '<td>' + item.OS + '</td>';
- html += '<td>' + item.PrcessorType + '</td>';
- html += '<td>' + item.RAM + '</td>';
- html += '<td>' + item.ScreenSize + '</td>';
- html += '<td>' + item.TouchScreen + '</td>';
- html += '<td>' + item.BatteryLife + '</td>';
- html += '<td>' + item.Camera + '</td>';
- html += '<td>' + item.Model + '</td>';
- html += '<td>' + item.Condition + '</td>';
- html += '<td>' + item.Discount + '</td>';
- html += '<td><a class="menu-action rounded-btn btn menu-icon vd_bd-grey vd_grey" data-toggle="tooltip" href="#" onclick="return GetProductDetail(' + item.ProductID + ')"><i class="fa fa-pencil"></i></a> | <a href="#" onclick="Delete(' + item.ProductID + ')"><i class="fa fa-thrash"></i></a></td>';
- });
- $('tbody').append(html);
- },
- error: function (errormessage) {
- alert(errormessage.responseText);
- },
- });
- }
- </script>