0

私はmvc3かみそりの新人です。私の問題は次のとおりです。

jqueryメソッドから変数を受け取ることができるこのactionResultメソッドがあります

変数が NULL になる理由

Cシャープ :

public ActionResult GetOrdersSP(int? StoreId, int? SupplierId)
        {
            bool count = false;

            var model = _storeOrderService.GetStoreSuppOrders(StoreId, SupplierId);

            if (model.Count() > 0)
            {
                count = true;
                return Json(count, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(count, JsonRequestBehavior.AllowGet);
            }
        }

これは私のjqueryです

$.fn.GetCount = function (data) {
        var storeid = $('#StoreId').val();
        var Supplierid = $('#Supplierid').val();
        if (ValidateCreateOrder('#StoreId', '#Supplierid')) {
            alert(storeid);
            alert(Supplierid);

            $.ajax(
                {
                    url: '<%: Url.Action("GetOrdersSP", "StoreOrder")%>',
                    type: 'json',
                    data: { StoreId: $('#StoreId').val(),
                        SupplierId: $('#SupplierId').val()
                    },
                    success: function (json) {

                        //should popup the modal 
                        alert(true);
                    }
                });
        }
    }

ストア ID とサプライヤ ID がアラートに正しく表示されることに注意してください。

ありがとう

4

1 に答える 1

0

データをjsonに変換し、actionResultで解析する必要があると思います.

この投稿を参照 jquery ajax を使用してパラメーターをコントローラーに渡す

于 2012-07-17T06:02:24.963 に答える