Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Convert Ajax,ActionLink to ajax

$
0
0

I have the following @Ajax.ActionLink in a partialview.

 @Ajax.ActionLink("Add", // <-- Text to display"MyMethod", // <-- Action Method Name
      new { id = item.ID, catid = item.CategoryID }, // <-- Route Values (parameter to pass to controller)
      new AjaxOptions
      {
          UpdateTargetId = (item.categories.Category + "Div").Replace(" ", ""), // <-- DOM element ID to update
          InsertionMode = InsertionMode.InsertAfter, // <-- Replace the content of DOM element
          OnSuccess = "removeDuplicateRows('.myclass')",
          HttpMethod = "GET" // <-- HTTP method
      },

I need to perform the same action from a JavaScript function. So I've got the below so far:

function(){
$.ajax({ type: 'get', url: '@Url.Action("MyMethod")', contentType: 'application/json; charset=utf-8', dataType: 'html', data: { "id": id, "catid": catid}, success: function (result) { // do things on success }, error: function (ex) { // do things on fail } });
}

How can I convert the ActionLink options into the $.ajax function.

Thanks in advance
Adam


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>