从客户端(Jquery)向服务器(WCF)发送自定义对象

如何从客户端(jquery)向服务器(WCF服务)发送自定义对象

传递对象的方式是什么? 下面是我的代码,当我在萤火虫中看到这是我得到的请看屏幕截图: 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) { // }); }); 
  • 这是我的WCF服务看起来像:

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