Ajax doesn't trigger server action

I am trying to trigger action via ajax but it doesn't call from some reason. Is my js code fine?

@Html.ActionLink("LIKE", "LikeComment", "Comments", new { id = 1985 }, new{@class = "likeButton"})

$(document).ready(function () {
        $(".likeButton").click(function () {            
            $.ajax({
                url: $(this).data("action-url"),
                cache: false,
                success: function (html) {
                    alert('ss');
                }
            });
            return false;
        });
    });

Answers


try this

$(document).ready(function () {
        $(".likeButton").click(function () {            
            $.ajax({
                url: $(this).attr("href"),
                cache: false,
                success: function (html) {
                    alert('ss');
                }
            });
            return false;
        });
    });

If your button code is LIKE then this part of ajax request is wrong:

This is wrong url: $(this).data("action-url"),

Do it like this url: $(this).attr("href"),


Need Your Help

Is there a way to grab the date and time out of a editText

android datetime

I have two editText one for date and one for time. Is there a way to get the info from both so I can use the code below and store the correct date and time?

S3 Backup Memory Usage in Python

python memory upload amazon-s3

I currently use WebFaction for my hosting with the basic package that gives us 80MB of RAM. This is more than adequate for our needs at the moment, apart from our backups. We do our own backups to S3