Abhilash J A

Abhilash J A

  • 533
  • 2.4k
  • 598.2k

The id is not defined jquery error MVC 5

Jan 10 2017 4:01 AM
 Hello every one,
 
I am working on mvc5 with visual studio 2015. I am using products.js file and called this products.js file on _Layout.cshtml page as shown below,
 
 
 
 
 
 
I have added this jquery code,
 
  1. passproductid = {  
  2.     passid: function () {  
  3.   
  4.         $('.edit_product').on('click'function (e) {  
  5.             debugger;  
  6.             var _productId = $(this).attr('id');  
  7.             $.ajax({  
  8.                 url: '/ProductCategory/GetProducts/',  
  9.                 type: "POST",  
  10.                 data: { productid: _productId.substring(10) },  
  11.                 success: function (data) {  
  12.   
  13.                    $('#divresult').html(data);  
  14.                 }  
  15.             });  
  16.         });  
  17.     }  
  18. }  
 after I have called this jquery function throught table tr click to get row id like this, 
  1. @foreach (var item in Model)  
  2.            {  
  3.            <tr id="[email protected]" onclick="return passproductid.passid()" class="edit_product">  
 but getting this error, 
 
 
 
How can I solve this? 

Answers (2)