Monday, May 27, 2013

Jquery Ajax post Custom Object as Json to Wcf Service


function LoadMore() {

    var myData =
    {
        arguments : {
            Category: "Main",
            SearchText: "",
        }
    };


    var jsonedArguments = JSON.stringify(myData);

    $.ajax({
        type: "POST",
        url: "/PublicService.svc/LoadMore",
        contentType: "application/json; charset=utf-8",
        cache: false,
        data: jsonedArguments,
        dataType: "json",
        processdata: true,
        success: function (data) {
         
            debugger;
            var xx = data;

        },
        error: function (msg) {
            alert('CallFiles failed!!!!');
        }
    });
}



 [OperationContract]
        [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
        public GetFilesResult LoadMore(GetFilesArguments arguments)
        {
            return new GetFilesResult() { TotalCount = 100 };
        }

No comments:

Post a Comment