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);
}
});
- 浏览: 60411 次
最新评论
-
flex_莫冲:
有社区开源版本的!
【原创】开源Sugar CRM 6.5.9 安装配置及汉化
相关推荐
本文将详细讲解如何使用jQuery AJAX来访问WCF(Windows Communication Foundation)服务,实现GET、POST、PUT和DELETE这四种HTTP操作,这些操作对应于CRUD(创建、读取、更新和删除)的基本数据库操作。 首先,WCF...
2. **修改(Edit)**:当用户编辑datagrid中的某行数据后,触发保存事件,同样使用Ajax发送PUT或PATCH请求,更新服务器上的对应记录。服务器确认更新成功后,返回确认信息,前端更新显示。 3. **删除(Delete)**:...
我们要访问一个对象的属性,只需要使用【对象名.属性名】的方式访问即可。例如:`var jsons = {"key1":"abc", ...}; alert(jsons.key1); // "abc"` JSON 中两个常用的方法 JSON 对象和字符串对象的互转有两个常用...
这个例子展示了如何使用jQuery发起一个JSON格式的AJAX GET请求,并在成功时解析返回的JSON数据。 另外,i18n(Internationalization,国际化)是软件开发中的一个重要概念,它涉及到软件如何适应不同地区的语言和...
JavaScript部分,我们使用jQuery来处理提交事件。由于IE6不支持直接的`$("#form1").submit();`,我们需要针对IE浏览器进行特殊处理: ```javascript $(function() { if ($.browser.msie) { window.form1.submit()...
最近在研究有关.net mvc项目中的session失效问题,下面小编把研究过程给大家共享下,大家可以参考下。 最近解决基于.net mvc项目的session...•无权限认证的Action,使用原生JQuery Ajax请求; •无权限认证的Action,
项目 sudo apt安装python3-venv sudo apt安装python3-dev python3 -m venv venv源venv / bin / activate pip3安装轮pip3安装python-jose pip3安装-r requirements.txt 数据库 sudo apt install mongodb-server设置...