尝试将多个参数传递给ajax调用失败

时间:2014-03-21 15:28:27

标签: c# javascript jquery ajax wcf

我正在尝试将多个参数传递给JQuery $ .ajax函数,当它们到达被调用的Web服务时,它们似乎是空白的。如果我传递一个参数,它似乎到达那里。功能是:

function callGetDataAndUpdateGrid(input, startIndex, maximumRows) {
            var gridRequest = {
                requestGUID: input,
                startIndex: startIndex,
                maximumRows: maximumRows,
            };

            console.log(input);

            $.ajax({
                url: "http://www.blah.com/services/TestsService.svc/GetContactsDataAndCountbyGUID",
                type: "GET",
                contentType: "application/json; charset=utf-8",
                data: gridRequest,
                dataType: "json",
                success: function (result) {
                    updateGrid(result.Data);
                    updateVirtualItemCount(result.Count);
                },

                error: function (jqXHR, textStatus, errThrown) {
                    console.log("AJAX call failed in callUpdateGrid");
                    console.log(errThrown);
                }
            });
        }

输入是一个JSON字符串,它来自调用上述函数的函数:

function pageLoad(sender, eventArgs) {
            var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
            var input = { "requestGUID": "<%=guid %>" };
            GetDataFromServer(input, 0, tableView.get_pageSize());
        }

        function GetDataFromServer(input, startIndex, maximumRows) {
            $.ajax({
                url: "http://www.blah.com/services/TestsService.svc/IsDataReady",
                type: "GET",
                contentType: "application/json; charset=utf-8",
                data: input,
                // dataType: "json",
                success: function (data) {
                    if (!data) {
                       setTimeout(function (inputInner) { GetDataFromServer(inputInner); }, 1000);                    } else {
                        console.log("data returned - calling callUpDateGrid");
                        console.log(input);
                        //Continue as data is ready
                        callGetDataAndUpdateGrid(input, startIndex, maximumRows);
                    }
                },
                error: function (jqXHR, textStatus, errThrown) {
                    console.log("AJAX call failed in CallIsDataReady");
                    console.log(errThrown);
                }
            });
        }

var input = {&#34; requestGUID&#34;:&#34;&lt;%= guid%&gt;&#34; };使它成为第一个由Entity Framework代码记录到数据库中的函数。在callGetDataAndUpdateGrid函数上它没有。当我传递一个参数(输入)时,它就在那里。 EF代码记录它是空白的。那么如何传递多个参数?我有太多称为输入的变量吗?

顺便说一句,WCF网络方法的签名是:

[OperationContract]
        [WebGet(ResponseFormat = WebMessageFormat.Json)]
        // [WebGet]
        public ResultData GetContactsDataAndCountbyGUID(string requestGUID, int startIndex, int maximumRows)

0 个答案:

没有答案