$("#orderBtn").click(function () {
var menuMap = {};
$("#menu-body > tr").each(function () {
var menu_number = $(this).children(".count").children().val();
if (menu_number > 0) {
var menu_id = $(this).attr("id");
menuMap[menu_id] = {
"MenuId": menu_id,
"MenuNumber": menu_number
};
}
});
var data = JSON.stringify(menuMap);
var url = "https://localhost:7274/Order/Create";
$.ajax({
url: url,
type: "post",
data: { "data": data },
success: function (response) {
},
error: function (xhr, status, error) {
}
})
});
public class OrderController : Controller
{
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(string data)
{}
}
why can’t I request my orderController’s Create Method?
When I use ajax to request , it shows 400 bad request.
I tried to console.log the wrong message,but In three parameter xhr,status,error only status shows error message.
1