Ajax中參數帶有html格式的 傳入後台儲存【二】

來源:互聯網
上載者:User

標籤:alert   ext   rem   ace   參數   erb   ejs   type   size   

    KindEditor.ready(function (K) {       //編輯器外掛程式        window.editor1 = K.create(‘#ctjs‘, {            uploadJson: ‘/Hotelgl/UploadImage‘,            allowFileManager: false ,  //允許圖片管理 開啟後再挑選圖片的時候可以直接從圖片空間內挑選            width: ‘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     })

 

Ajax中參數帶有html格式的 傳入後台儲存【二】

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.