使用Jquery Aajx访问WCF服务(GET、POST、PUT、DELETE)
更新时间:2012年03月16日 21:34:33 作者:
使用Jquery Aajx访问WCF服务(GET、POST、PUT、DELETE),需要的朋友可以参考下
复制代码 代码如下:
using jquery ajax call wcf service get/post/put/delete
http://www.codeproject.com/Articles/254714/Implement-CRUD-operations-using-RESTful-WCF-Servic
Using POST Method
Retrieve a representation of the addressed member of the collection, in the example below, create a new entry in the collection.
Collapse | Copy Code
$.ajax({
type: "POST",
url: "Services/EFService.svc/Members/",
data: "{Email:'test@test.com', ScreenName:'TestUser'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) { // Play with response returned in JSON format },
error: function (msg) {
alert(msg);
}
}); Using PUT Method
Update the entire collection with another collection, in the example below, update the addressed member of the collection.
Collapse | Copy Code
$.ajax({
type: "PUT",
url: "Services/EFService.svc/Members/",
data: "{Email:'test@test.com', ScreenName:'TestUser'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) { // Play with response returned in JSON format },
error: function (msg) {
alert(msg);
}
});Using DELETE Method
Delete the entire collection or a specific collection, in the example below, delete Member with id=1.
Collapse | Copy Code
$.ajax({
type: "DELETE",
url: "Services/EFService.svc/Members(1)",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) { // Play with response returned in JSON format },
error: function (msg) {
alert(msg);
}
});
相关文章
jQuery插件EnPlaceholder实现输入框提示文字
EnPlaceholder插件支持密码框哦!实际对比同类的placeholder插件在ie等浏览器下效果要好很多!下面我们来具体探讨下此插件的使用方法吧。2015-06-06解析页面加载与js函数的执行 onload or ready
这篇文章主要介绍了页面加载与js函数的执行 onload or ready 需要的朋友可以过来参考下,希望对大家有所帮助2013-12-12
最新评论