Reputation: 1090
Im trying to make a table row clickable using javascript. I have a table with customers and when the row is clicked, it should forward to the detals view. But now im stuck with the javascript. First of all I cant seem to get the id of the row.. and second it dosent seem to call the Details method in the Customer controller... my javascript:
<script type="text/javascript">
$(document).ready(function(){
$('#customers tr').click(function () {
var id = $(this).id;
$.ajax({
url: '@Url.Action("Details","Customer")',
type: 'GET',
data: { id: id }
});
})
})
Upvotes: 1
Views: 2777
Reputation: 33554
to get the id you need to do:
var id = $(this).attr( 'id' );
not sure about the other part, can you view the source in browser and verify the url?
Upvotes: 1