教程集 www.jiaochengji.com
教程集 >  jQuery  >  jquery 教程  >  正文 使用Jquery Aajx访问WCF服务(GET、POST、PUT、DELETE)

使用Jquery Aajx访问WCF服务(GET、POST、PUT、DELETE)

发布时间:2013-05-30   编辑:jiaochengji.com
使用Jquery Aajx访问WCF服务(GET、POST、PUT、DELETE),需要的朋友可以参考下
使用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);
}
});

image

image

您可能感兴趣的文章:
使用Jquery Aajx访问WCF服务(GET、POST、PUT、DELETE)
局域网内使用代理WCF无法访如何解决?
web API接口及restful规范详解
restful设计方法
Python2爬虫入门:Urllib的高级用法
php中get和post的区别是什么?
在php中get和post区别
jQuery调用RESTful WCF示例代码(GET方法/POST方法)
简单理解Web Service三种实现方式
HTTP中Get与Post的区别有哪些

[关闭]
~ ~