Run an action on link click, jQuery
I have a series of images, and I simply want to record when each is clicked. They never show up in their own view, so running the code there is worthless.
I've wired up a click event using jQuery. Though the $.post doesn't work. Any idea how I can achieve what I am trying? The 'hit' is just an HTML element stored in the view when it draws the link for the im开发者_如何学JAVAage. Hit refers to HitController, and then the "Hit" method accepts an id.
Yeah, I fixed the id error - still not working though.
$("a[hit]").each(function() {
$(this).click(function() {
var hit = $(this).attr("hit");
$.post("Hit/Hit/", { id: hit });
});
});
hmm, id could possibly be an undefined variable, does alert(id) show the proper result?
精彩评论