使用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:'[email protected]', 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:'[email protected]', 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); } });
相关推荐
Guanjs0 2020-11-09
wmsjlihuan 2020-09-15
shishengsoft 2020-09-15
poplpsure 2020-08-17
CyborgLin 2020-08-15
Richardxx 2020-07-26
sunnyhappy0 2020-07-26
knightwatch 2020-07-19
wcqwcq 2020-07-04
chichichi0 2020-06-16
YAruli 2020-06-13
JF0 2020-06-13
84423067 2020-06-12
心丨悦 2020-06-11
zkwgpp 2020-06-04
stoneechogx 2020-06-04
litterfrog 2020-05-30
today0 2020-05-26