zoukankan      html  css  js  c++  java
  • Ajax中参数带有html格式的 传入后台保存【二】

        KindEditor.ready(function (K) {       //编辑器插件
            window.editor1 = K.create('#ctjs', {
                uploadJson: '/Hotelgl/UploadImage',
                allowFileManager: false ,  //允许图片管理 开启后再挑选图片的时候可以直接从图片空间内挑选
                 '480px',
                height: '150px',
                afterBlur: function () { this.sync(); }
            });
            K('#ctjs').click(function () {
                editor1.loadPlugin('image', function () {
                    editor1.plugin.imageDialog({
                        showRemote: false,
                        imageUrl: K('#PicUrl').val(),
                        clickFn: function (url, message, error) {
                            alert("上传成功!");
                            editor1.hideDialog();
                        }
                    });
                });
            });
        });

    AJAX:   利用encodeURIComponent(text)转码

      $.ajax({                             //异步添加
                        type: "POST",
                        url: "/Repast/ctgladd",
                        data: { tjctmz: $.trim($('#ctmz').val()), tjctsj: $.trim($('#ctsj').val()), tjctwz: $.trim($('#ctwz').val()), tjctdh: $.trim($('#ctdh').val()), tjctjs: encodeURIComponent(text), hotelid: hotelid, gnbh: parseInt($("#gnbh").val()), cz: cz },
                        success: function (data) {
                            var f = $.parseJSON(data);
                            if (f.yz) {
                                alert("添加成功!");
                                if ($("#ctcx").length > 0) {
                                    $('.catering_details p dfn').trigger("click");
                                    $("#ctcx").trigger("click");
                                } else {
                                    location.replace(location.href);
                                }
                            }
                            else {
                                alert("添加失败!");
                                location.replace(location.href);
                            }
                        }
                    })

    前台显示:decodeURIComponent(f.ctjs)

     1  //------查询-------------
     2     $(".catering_page").delegate('li .details', {
     3         click: function (e) {
     4             $('#show').show();
     5             $("#show .btn_ok").attr("name", $(this).attr("name"));
     6             xgid = parseInt($(this).attr("value"));   //全局变量保存数据库指定对应id号
     7             $.ajax({
     8                 type: "POST",
     9                 url: "/Repast/ctglcx",
    10                 data: { cxid: xgid },
    11                 success: function (data) {
    12                     var f = $.parseJSON(data);
    13                     $("#ctmz").val(f.name);
    14                     $("#ctsj").val(f.time);
    15                     $('#ctwz').val(f.address);
    16                     $('#ctdh').val(f.tel);
    17                     editor1.html(decodeURIComponent(f.ctjs));
    18                 }
    19             })
    20         }
    21     })

    a.jdxx = HttpUtility.UrlDecode(jdxx);   //url码继续转化位标准标签格式

    %3Cdiv%20align%3D%22center%22%3E%0A%09%3Cspan%20style%3D%22background-color%

    转化

    <span> xxxx </span><b></b> ........

  • 相关阅读:
    存储器多级结构
    649. Dota2 参议院
    pycharm安装第三方库失败
    python -m pip install --upgrade pip升级失败
    P1149 火柴棒等式
    HTTP详解
    ref与out
    EF查询数据库框架的搭建
    EF查询数据库框架的搭建
    css清除浮动
  • 原文地址:https://www.cnblogs.com/h5monkey/p/6096853.html
Copyright © 2011-2022 走看看