开发者

Run an action on link click, jQuery

开发者 https://www.devze.com 2022-12-17 18:06 出处:网络
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 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号