使用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);
}
});

image

image

相关文章

  • jQuery实现鼠标划过添加和删除class的方法

    jQuery实现鼠标划过添加和删除class的方法

    这篇文章主要介绍了jQuery实现鼠标划过添加和删除class的方法,涉及jQuery鼠标事件及页面样式的相关操作技巧,需要的朋友可以参考下
    2015-06-06
  • jQuery实现表格展开与折叠的方法

    jQuery实现表格展开与折叠的方法

    这篇文章主要介绍了jQuery实现表格展开与折叠的方法,涉及jQuery中toggleClass方法与链式操作的相关技巧,非常简单实用,需要的朋友可以参考下
    2015-05-05
  • jquery.ajax之beforeSend方法使用介绍

    jquery.ajax之beforeSend方法使用介绍

    这篇文章主要介绍了jquery.ajax之beforeSend方法使用介绍,beforeSend方法用于在向服务器发送请求前添加一些处理函数,需要的朋友可以参考下
    2014-12-12
  • 使用js+jquery实现无限极联动

    使用js+jquery实现无限极联动

    本篇文章是对可扩展的无限极联动下拉选项的实例进行了分析介绍,需要的朋友参考下
    2013-05-05
  • jQuery层级选择器用法分析

    jQuery层级选择器用法分析

    这篇文章主要介绍了jQuery层级选择器用法,实例分析了常见的四种层级选择器的使用技巧,并给出了实例总结,需要的朋友可以参考下
    2015-02-02
  • jquery获取复选框的值的简单实例

    jquery获取复选框的值的简单实例

    下面小编就为大家带来一篇jquery获取复选框的值的简单实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2016-05-05
  • 模拟多级复选框效果的jquery代码

    模拟多级复选框效果的jquery代码

    今天又次体会到jquery的强大了,做了个多级复选框的效果,代码块分两块:一是全选的效果、二是当前复选框的父框根据当前框的兄弟是否全选中来决定父框是否选中
    2013-08-08
  • jquery选择器大全 全面详解jquery选择器

    jquery选择器大全 全面详解jquery选择器

    jQuery选择器使得获得页面元素变得更加容易、更加灵活,从而大大减轻了开发人员的压力。如同盖楼一样,没有砖瓦,就盖不起楼房。得不到元素谈何其他各种操作呢?可见,jQuery选择器的重要性。当然想一下子掌握所有选择器也是很困难的,这个得靠实践和积累
    2014-03-03
  • jquery.cookie.js实现用户登录保存密码功能的方法

    jquery.cookie.js实现用户登录保存密码功能的方法

    这篇文章主要介绍了jquery.cookie.js实现用户登录保存密码功能的方法,结合实例形式详细分析了jquery.cookie.js插件操作cookie实现保存用户登录信息的相关技巧,需要的朋友可以参考下
    2016-04-04
  • jquery点击获取动态数据进行传参问题

    jquery点击获取动态数据进行传参问题

    这篇文章主要介绍了jquery点击获取动态数据进行传参问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2022-12-12

最新评论