使用Jquery Aajx訪問WCF服務(wù)(GET、POST、PUT、DELETE)
更新時間: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判斷一個元素是否含有一個指定的類(class)實例
下面小編就為大家?guī)硪黄褂胘query判斷一個元素是否含有一個指定的類(class)實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-02-02細(xì)說瀏覽器特性檢測(1)-jQuery1.4添加部分
瀏覽器特性檢測即通過探測對象是否擁有某個屬性或者函數(shù),或者通過其他的編碼探測方式,來決定其是否支持某一功能、特性。2010-11-11基于jQuery創(chuàng)建鼠標(biāo)懸停效果的方法
這篇文章主要介紹了基于jQuery創(chuàng)建鼠標(biāo)懸停效果的方法,實例分析了jQuery實現(xiàn)鼠標(biāo)特效的原理與詳細(xì)步驟,具有一定參考借鑒價值,需要的朋友可以參考下2015-03-03jQuery基于muipicker實現(xiàn)仿ios時間選擇
本文給大家分享的是把jQuery的muipicker插件修改實現(xiàn)仿IOS時間選擇特效,非常的不錯,有需要的小伙伴可以參考下。2016-02-02Jquery UI實現(xiàn)一次拖拽多個選中的元素操作
這篇文章主要介紹了Jquery UI實現(xiàn)一次拖拽多個選中的元素操作,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-10-10