Jquery Rest与WCF 3.5的通信

Ron*_*nie 4 rest asp.net-mvc wcf jquery

我正在测试在asp.net mvc站点和WCF 3.5服务之间交换休息消息的基础知识.该服务使用在codeplex上找到的WCF REST入门工具包中的模板构建.我想用jquery交换json消息.REST Singleton服务正常运行,它还提供了所有可能调用的示例,在uri的末尾添加了help参数.我到达使用内置的jquery $ .getJSON执行GET请求.我在执行PUT(更新值)和POST时遇到问题.

$.ajax({
     type: "PUT",
     dataType: "json",
     url: "http://localhost:1045/Service.svc/?format=json",
     data: '{"Value":testvalue}'
 }); 
Run Code Online (Sandbox Code Playgroud)

对此最好的方法是什么?是否有可能根本不使用Ajax女士,绕过它是否正确?

Mot*_*ams 5

还要确保在ajax调用中正确设置了contentType.

contentType: "application/json"

JQuery默认是

contentType: "application/x-www-form-urlencoded"