开发者

sending custom object from client (Jquery) to server (WCF)

开发者 https://www.devze.com 2023-01-26 07:13 出处:网络
how to send a custom object from client (jquery) to server (WCF service) what is the way of passing an object? below is my code and when i see in the firebug this is what i get please see the screen

how to send a custom object from client (jquery) to server (WCF service)

what is the way of passing an object? below is my code and when i see in the firebug this is what i get please see the screen shot: http://img88.imageshack.us/img88/205/54211873.png

var CustomerInfo = {
                Name: '',
                Address: ''
            };

            function buildNewCustomerRequest() {
                var request = {
                    CustomerInfo: CustomerInfo
                };
                request.CustomerInfo.FirstName = $("#Name").val();
                request.CustomerInfo.Address = $("#Address").val(); 

                return request;
            }



     $("#getcustomerobject").click(function (event) {
                    var request = buildNewCustomerRequest();
                     var json = JSON.stringify(request);
                    $.getJSON('http://host/MyService.svc/GetCusto
merObject?CustomerObject=?', { request: json }, function (customer) {

                        //
                    });
                });

 <li>
            <label id="lblFirstName" for="Name">
              First Name :
            </label>
            <input id="Name" name="Name" type="text" maxlength="25" class="required" />  </li>
          <li>
            <label id="lbllastName" for="开发者_JAVA技巧Address">
              Address :
            </label>
            <input id="Address" name="Address" type="text" maxlength="25" class="required" /><em> </li>
          <li>

here is my WCF service looks like:

public bool GetCustomerObject(string method, Customer customer)
        {
            if (customer.Name == "test")
                return true;
            return false;
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消