I have a link like this
<a class="viewp" href="#">@data.name</a>
and I would like to call a jquery ajax this way
$(document).ready(function ()
{
$('.viewp').click(function (id)
{
var responseUrl="~/click?id="+id;
$.ajax(
{
type: "GET",
data:id,
url:responseUrl,
success:success
});
});
});
But I don't know how the id
of the @data.name
is passed into the jquery function.
If I replace the above link's href
with href="~/click?id=@data.id"
then that is supposed to load the whole page not some specific region and clearly ajax doesn't work also.
[UPDATE]
By id
I would mean the id
primary key of my sql table and I am using webmatrix to code my simple web page. My database table looks like this create table x(id, name)