当前位置:首页 > 开发 > Web前端 > Jquery > 正文

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

发表于: 2013-08-30   作者:一炮送你回车库   来源:转载   浏览:
摘要: 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 represe

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 Aajx访问RESTful服务(GET、POST、PUT、DELETE)

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
http://www.elharo.com/blog/software-development/web-development/2005/12/08/post-vs-put/ chins
原文: 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【五】——在Web Api中实现Http方法(P
系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 在Web Api中,我们对资源的CRUD操
ASP.NET交互Rest服务接口(Jquery的Get与Post方式) 本文将通过一个简单的实例,介绍如何创建一个Res
本文将通过一个简单的实例,介绍如何创建一个Rest服务接口,以及通过JQUERY去对它进行调用;主要采取两
http://www.cnblogs.com/wujy/p/3386993.html 本文将通过一个简单的实例,介绍如何创建一个Rest服务
在Web Api中实现Http方法(Put,Post,Delete) 系列导航地址http://www.cnblogs.com/fzrain/p/3490137.
上一次实践是将Restlet与spring集成,本次实践是将实现POST、PUT和DELETE方法。 参考: http://ajaxc
Rest 它是用于创建分布式超文本媒体的一种架构方式,我们可以通过标准的HTTP(GET,POST,PUT,DELE
一直以来都想找一种数据通信方式,就像是asp.net中的*ashx程序一样的应用,什么意思呢,就是不论是
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号