zoukankan      html  css  js  c++  java
  • 使用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:'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);
               }
           });
    image

    image

  • 相关阅读:
    jQuery中添加自定义或函数方法
    一定要明白采取是哪种提交方式,表…
    基本数据类型
    python之运算符
    Java之递归
    【偏序问题】三维偏序,四维偏序
    【复习笔记】主席树
    【bzoj1901】dynamic ranking(带修改主席树/树套树)
    【bzoj4530】大融合(LCT的子树维护)
    POJ1008 Maya Calendar
  • 原文地址:https://www.cnblogs.com/gossip/p/2400846.html
Copyright © 2011-2022 走看看