0

Jqueryの並べ替え可能なUIがありますユーザーがリマインダーの順序を更新するときにリマインダーの順序を更新するWebサービスがありますjsonデータをWebサービスに渡すのに問題があることはわかっていますが、解決できませんでした

エラー:
無効なWebサービス呼び出しの欠落値パラメーター:System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target、IDictionary 2 parameters) at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary2 parameters)のrlist System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context、WebServiceMethodData methodData、 IDictionary`2 rawParams)at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context、WebServiceMethodData methodData)

 Web Services 
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using Compudata_ProjectManager.CodeFile.BOL;
    using System.Data.SqlClient;
    using System.Web.Script.Services;

    namespace Compudata_ProjectManager.WebServices
    {
        /// <summary>
        /// Summary description for remindersWebService
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
         [ScriptService]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
        // [System.Web.Script.Services.ScriptService]
        public class remindersWebService : System.Web.Services.WebService
        {


            public class ReminderDTO
            {
                public int Id { get; set; }
                public int Order { get; set; }
            }

            [WebMethod]
            [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
            public string UpdateOrder(List<ReminderDTO> rList)
            {
                //CompuData_ProjectManagerConfiguration.DbconnctionString;

                using (SqlConnection connectionString = new SqlConnection(CompuData_ProjectManagerConfiguration.DbconnctionString))
                {

                    foreach (var r in rList)
                    {
                        string sSQL = "UPDATE [TaskManagementSystem_DB].[dbo].[Reminders] SET [reminderOrder] = " +  r.Order.ToString() + "where reminderID = " + r.Id;

                        SqlCommand cmd = new SqlCommand(sSQL, connectionString);

                        try
                        {
                            cmd.ExecuteNonQuery();
                        }
                        catch (SqlException)
                        {
                            return "falied";
                        }


                    }
                    return "save";
                }
            }
        }
    }

javascript 

    $(function () {
        $("#sortable").sortable({
            placeholder: "vacant",
            update: function (e, ui) {
                //process each li

                //create vars
                var orderArray = [];
                var wrap = {};
                $("#sortable li").each(function () {


                    //build ReminderObject
                    var reminderObject = {
                        Id: $(this).attr("id"),
                        Order: $(this).find("input[type='hidden']").val()
                    };

                    //add object to array 
                    orderArray.push(reminderObject);

                });

                wrap.d = orderArray


                //pass to server 
                $.ajax({
                    type: "POST",
                    url: "../WebServices/remindersWebService.asmx/UpdateOrder",
                    data: JSON.stringify(wrap),
                    processData: false,
                    contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        if (data.d === "saved") {
                            document.write("Save ok");
                        } else {
                            document.write("Save failed");
                        }
                    },
                    error: function (xhr, status, error) {
                        var err = eval("(" + xhr.responseText + ")");
                        console.log(err.StackTrace);
                        alert(err.Message);
                    }
                });

            } //end of update function 
        });
        $("#sortable").disableSelection();



        $("input[type=checkbox]").on("click", function () {
            $(this).nextAll().toggleClass("hidden");
        });

    });

</script>
4

1 に答える 1

0

期待どおりの整数で送信Idしてみてください。Order

var reminderObject = {
    Id: parseInt($(this).attr("id"), 10),
    Order: parseInt($(this).find("input[type='hidden']").val(), 10)
};

また、期待されるパラメータをそのままに変更wrap.d = orderArrayします。wrap.rList = orderArrayrList

于 2013-03-04T16:01:22.170 に答える