zoukankan      html  css  js  c++  java
  • 通过Ajax post Json类型的数据

     function postSimpleData() {
            $.ajax({
                type: "POST",
                url: "/Service/SimpleData",
                contentType: "application/json", //必须有
                dataType: "json", //表示返回值类型,不必须
                data: JSON.stringify({ 'foo': 'foovalue', 'bar': 'barvalue' }),  //相当于 //data: "{'str1':'foovalue', 'str2':'barvalue'}",
                success: function (jsonResult) {
                    alert(jsonResult);
                }
            });
        }
        function postListString() {
            $.ajax({
                type: "POST",
                url: "/Service/ListString",
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify({ "BuIds": ["1", "2", "3"] }),
                success: function (jsonResult) {
                    alert(jsonResult);
                }
            });
        }
        function postEmployees() {
            $.ajax({
                type: "POST",
                url: "/Service/Employees",
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify({
                    "Employees": [
                                        { "firstName": "Bill", "lastName": "Gates" },
                                        { "firstName": "George", "lastName": "Bush" },
                                        { "firstName": "Thomas", "lastName": "Carter" }
                                     ]
    
                }),
                success: function (jsonResult) {
                    alert(jsonResult);
                }
            });
        }
    

      

  • 相关阅读:
    android progressbar 水平进度条
    jquery 下拉自动加载
    jquery ajax
    input 数字,字母汉字的限制方法(转帖)
    Jquery checkbox
    js运用6
    js运用5
    js运用4
    js运用3
    js运用2
  • 原文地址:https://www.cnblogs.com/hjptopshow/p/8059389.html
Copyright © 2011-2022 走看看