Guys, Im calling a JsonResult but the "getJSON" is sending a null parameter to controller.
In JS I have this...
var ID = $("#Id").val();
$.g开发者_如何学CetJSON("/Orders/JSON", ID, function (data) {
....
};
The var ID has a valid value. I don't know where I'm going wrong.
public JsonResult JSONEnvolvidosPedido(string ped)
{
...
}
What am I missing?
Tks.
If you are sending data to a server, it needs to be in key=value
form. You're just sending a value.
You should probably do something like this:
$.getJSON("/Orders/JSON", {id: ID}, function (data) {
....
};
The exact name of the key (id
here) depends on your server-side code's requirements.
be sure to add JsonRequestBehavoir.AllowGet
return Json(data, JsonRequestBehavior.AllowGet);
精彩评论