4

Is there a way to replace the following code with some JQuery code that use unobtrusive javascript instead of what the MicrosoftAjax library does ?

<ul class="vote">
   <li>
      <%= Ajax.ActionLink("Up", "UpVote", new { VoteId = item.Id }, new AjaxOptions() { OnSuccess = "upVote(this)" }, null) %>  
   </li>
</ul>

1 Answer 1

4

Add a link with an Id attribute, then bind the click event to the function that will send the Ajax request.

<%= Html.ActionLink("Up","UpVote",new { VoteId = item.Id },new { id = "sendRequest" }) %>

Then with jQuery:

$('#sendRequest').click(function() {
  // $.getJSON or whatever ajax function you want to use
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.