zoukankan      html  css  js  c++  java
  • ajax调用实例

    function calculateIntegral() {
        var GPrice = document.getElementById("GiftMoeny").value;
        var CPrice = document.getElementById("CodeMoeny").value;
        var freight = document.getElementById("Shopfreight").value;
        $.ajax({
            type: "POST",
            url: "../Controller/UserCart/SubmitOrder.ashx",
            data: { HttpType: "UserJifenDikou", GiftPrice: GPrice, CardPrice: CPrice, Orderfreight: freight },
            cache: false, //设置时候从浏览器中读取 缓存  true 表示 是
            datatype: "json",
            success: function (data, status) {
                if (data != "") {
                    data = eval("(" + data + ")");
                    $("#IntegralMoeny").attr("value", data.ds[0].IntegralMoeny); //赋值积分抵扣金额
                    $("#lblJifenMoney").html(data.ds[0].IntegralMoeny);
                }
                TotalOrder();
            }
        });

    }

    public void ProcessRequest(HttpContext context)
        {
            string Type = context.Request.Form["HttpType"];

            if (Type == "UserJifenDikou")
            {
                string GiftPrice = context.Request.Form["GiftPrice"];
                string CardPrice = context.Request.Form["CardPrice"];
                string Orderfreight = context.Request.Form["Orderfreight"];

                context.Response.Write(IsIntegralAll(Convert.ToDecimal(GiftPrice), Convert.ToDecimal(CardPrice), Convert.ToDecimal(Orderfreight)));
            }
        }

        public string IsIntegralAll(decimal cartprice, decimal codePrice, decimal Orderfreight)
        {
            string strhtmldate = "";
            ShopCartHelp Help = new ShopCartHelp();
            decimal ShopMeony = Help.GetShopPrice();
            //如果用户可抵扣的金额大于剩余金额
            if (Help.UserIntegralMoeny() >= ShopMeony)
            {
                strhtmldate = "{\"ds\":[{\"IntegralMoeny\":" + ShopMeony + ",\"OrderMoeny\":\"" + Orderfreight + "\"}]}";
            }
            else
            {
                decimal OrderMoeny = 0;// dikouMoney - Help.UserIntegralMoeny();
                strhtmldate = "{\"ds\":[{\"IntegralMoeny\":" + Help.UserIntegralMoeny() + ",\"OrderMoeny\":\"" + OrderMoeny + "\"}]}";
            }
            return strhtmldate;
        }

  • 相关阅读:
    JS替换字符串多余的空格符
    WebStorm2017.3.4版本 注册码
    使用$.getJSON()需要注意的地方
    45道CSS基础面试题(附答案)
    单机版搭建Hadoop环境图文教程详解
    Ubuntu下安装JDK图文详解
    VMtools安装以及设置
    Ubuntu 12.04中文输入法的安装
    Hadoop 学习之 FAQ
    java ant 命令大全
  • 原文地址:https://www.cnblogs.com/doosmile/p/2304775.html
Copyright © 2011-2022 走看看