与WCF 3.5 jQuery的休息通信 [英] Jquery Rest communication with WCF 3.5

查看:217
本文介绍了与WCF 3.5 jQuery的休息通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试的基本知识的asp.net的MVC网站和WCF服务3.5之间交换休息的消息。
该服务使用在codePLEX发现WCF REST入门工具包中找到模板建造的。
我想交换使用jQuery JSON消息。
其余辛格尔顿服务是否正常工作,它也将提供帮助参数广告的URI结束所有可能的调用的例子。
我到达执行与内置jQuery的$ .getJSON GET请求。
我有做的PUT(更新值)和问题POST。

I'm testing the basics for exchanging rest messages between a asp.net mvc site and a WCF 3.5 service. The service is built using the template found in the WCF REST Starter Kit found on codeplex. I would like to exchange json messages using jquery. The REST Singleton service is working properly and it also provide examples of all the possible calling adding the help parameter ad the end of the uri. I arrive to perform GET requests with the built in jquery $.getJSON. I have problems doing the PUT (for updating values) and POST.

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

,这是什么最好的方法?是否有可能不使用Ajax女士一切,它是正确的绕过它?

What is the best approach for this? Is it possible not to use Ms. Ajax at all and is it correct to bypass it?

推荐答案

PUT和删除没有被所有的浏览器根据jQuery的支持

"PUT" and "DELETE" are not supported by all browsers according to jQuery

该类型的请求作出(POST或
  GET),默认是GET。注:其他
  HTTP请求方法,如PUT和
  DELETE,也可以在这里使用的,但
  它们不被所有受支持的
  浏览器。

The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.

http://docs.jquery.com/Ajax/jQuery.ajax#options

我真的不明白你的问题虽然。你是否有做一个PUT和POST或只是一个POST问题吗?是否GET做工精细?

I didn't really understand your question though. Are you having a problem doing a PUT and a POST or just a POST? Does the GET work fine?

这是我注意到你的数据的一个错误,注意我说这不包括引号。

One error that I noticed was your data, notice I added it without quotes.

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

这篇关于与WCF 3.5 jQuery的休息通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆