使用Jquery Aajx訪問WCF服務(wù)(GET、POST、PUT、DELETE)
更新時(shí)間:2012年03月16日 21:34:33 作者:
使用Jquery Aajx訪問WCF服務(wù)(GET、POST、PUT、DELETE),需要的朋友可以參考下
復(fù)制代碼 代碼如下:
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);
}
});
相關(guān)文章
jQuery實(shí)現(xiàn)鼠標(biāo)劃過添加和刪除class的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)鼠標(biāo)劃過添加和刪除class的方法,涉及jQuery鼠標(biāo)事件及頁面樣式的相關(guān)操作技巧,需要的朋友可以參考下2015-06-06
使用js+jquery實(shí)現(xiàn)無限極聯(lián)動(dòng)
本篇文章是對可擴(kuò)展的無限極聯(lián)動(dòng)下拉選項(xiàng)的實(shí)例進(jìn)行了分析介紹,需要的朋友參考下2013-05-05
jquery.cookie.js實(shí)現(xiàn)用戶登錄保存密碼功能的方法
這篇文章主要介紹了jquery.cookie.js實(shí)現(xiàn)用戶登錄保存密碼功能的方法,結(jié)合實(shí)例形式詳細(xì)分析了jquery.cookie.js插件操作cookie實(shí)現(xiàn)保存用戶登錄信息的相關(guān)技巧,需要的朋友可以參考下2016-04-04
jquery點(diǎn)擊獲取動(dòng)態(tài)數(shù)據(jù)進(jìn)行傳參問題
這篇文章主要介紹了jquery點(diǎn)擊獲取動(dòng)態(tài)數(shù)據(jù)進(jìn)行傳參問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12


