使用 JQuery,我将值传递给 Controller 中的操作。 customerId 和 ProductId 不为空:
$.ajax({
type: "GET",
url: "Customer/Product/",
data: { Customer: customerID, Product: productId},
dataType: "json",
error: function (xhr, status, error) {
// you may need to handle me if the json is invalid
// this is the ajax object
},
success: function (json) {
$("#productName").innerHTML = json;
alert(json);
alert($("#startDate").innerHTML);
}
});
在 MVC3 Controller 中,我有以下操作:
public ActionResult Product(string Customer, string Product)
{
//both are null
}
我不知道为什么两者都为空?请指导
最佳答案
$.ajax({
type: "GET",
url: "Customer/Product/",
data: "Customer="+customerID +"&Product="+productId,
dataType: "json",
error: function (xhr, status, error) {
// you may need to handle me if the json is invalid
// this is the ajax object
},
success: function (json) {
$("#productName").innerHTML = json;
alert(json);
alert($("#startDate").innerHTML);
}
});
试试这个方法。
关于c# - MVC3 Controller 未接收任何参数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8775162/