get contents of div and post to db from ajax Actionlink mvc4
This code retrieves clicked items and updates a div on a page that has a
submit button in it. How do I get the contents of that div, post to db and
return to previous page?
I know it's a lot but I can't get a grip on posting with Ajax.
$(".ITA").on("click", "li", function () {
var div = $("#AddedItems");
var parent = $(this).closest("ul");
var itemtoadd = parent.find("[data-id]").attr("data-id");
var name = parent.find("[data-name]").attr("data-name");
alert(itemtoadd + name);
//how to get these and post to db?
var itemtoadd = ("<li class = " + itemtoadd + ">" + name + "</li>");
alert(itemtoadd); //for debug
$(itemtoadd).appendTo(div);
});
I didn't get far with the link
@Ajax.ActionLink(
"Submit", "PostToDb",
new AjaxOptions {
HttpMethod = "POST",
//what to do with data:?
})
No comments:
Post a Comment