Hi all I have an ajax which has to post data to my controller action method,but the post function is not firing it does not hit my Action Method, can any one tell me where I am doing wrong, function save menu I call on onclick function of my button,every thing is going good it’s going the function savemenu and parsetree but my ajax method is not firing:
function savemenu() {
var columns = $("#columnholder > div").length;
$("#columnholder > div").each(function (data) {
var divid = $(this).attr("id");
parseTree(divid);
});
}
function parseTree(ul) {
var brand = "";
var parent;
alert(ul);
$("#" + ul).find("ol").each(function (event, ui) {
$("#" + ul).find("li").each(function () {
parent = $(this).attr("parent");
if ($(this).children("span").length) {
brand = brand + $(this).children("span").html() + '~' + $(this).children("span").attr('id') + "=>" + parent + '|';
alert(brand);
}
});
return false;
});
var postdata = JSON.stringify(brand);
var MenuBuilderURL = '@Url.Action("MenuDrag","MenuBuilder")';
alert(MenuBuilderURL);
$.ajax({
type: "POST",
url: "/MenuBuilder/MenuDrag/",
dataType: "json",
data: JSON.stringify(brand),
contentType: 'application/json; charset=utf-8',
success: function (data) {
alert(data.Result);
},
traditional: true
});
}
here is my controller action method
public ActionResult MenuDrag()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult MenuDrag(List<String> data)
{
return View();
}
can any one help me out here please
As you said the ajax call is hiting your method,now if you want to post your string to the action
replace
with
and in your ajax post method
hope it will helps you