c# - MVC3 Controller 未接收任何参数值

标签 c# jquery asp.net-mvc-3

使用 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/

相关文章:

jquery - 如何在验证事件上显示弹出窗口?

c# - 将有序结果组织到带标签的部分

C# P/调用 : Pointer to string as error message

javascript - jQuery sum TD 点击事件

javascript - jQuery Ajax 竞争条件?

asp.net-mvc - ASP.NET MVC非侵入式验证-为什么需要表单上下文?

c# - XmlTextWriter - 访问路径被拒绝

c# - 线程安全事件调用

javascript - 为什么在 jQuery 中使用 load() 而不是 htmls?

asp.net-mvc-3 - 如何将强类型模型作为数据参数传递给jquery ajax post?