I am totally confused on how to do ajax stuffs with jQuery and it seems the more I try the more confused I get. At this point all I want to do is get data to my controller using jQuery ajax. Some code for my jquery ajax call is.
$(function() {
$('#buttonAddLink').click(function() {
var AjaxLink = {
title: $("#linkTitle").val(),
url: $("#linkUrl").val()
};
$.ajax({
url: '/User/AddLink',
type: 'POST',
data: AjaxLink,
dataType: 'json',
success: function(result){
$('.added').html(result.Result).show();
}
});
});
});
Here is my controller and Action I am using. From trying to look at several tutorials it "should" work to the best of my knowledge, but apparently I don't get it like I thought I did.
public ActionResult AddLink(string title, string url)
{
return Json(new { Result = string.Format(title + " " + url)});
}
All I am basically trying to do with that is do the Ajax call and return it to display just to make sure data was sent to the controller.